GuardB->setCallingConv(CC);
return eraseInstFromFunction(*II);
}
+
+ // guard(!(a || b)) -> guard(!a); guard(!b);
+ if (match(IIOperand, m_Not(m_Or(m_Value(A), m_Value(B))))) {
+ CallInst *GuardA = Builder->CreateCall(
+ GuardIntrinsic, Builder->CreateNot(A), {DeoptOB}, II->getName());
+ CallInst *GuardB = Builder->CreateCall(
+ GuardIntrinsic, Builder->CreateNot(B), {DeoptOB}, II->getName());
+ auto CC = II->getCallingConv();
+ GuardA->setCallingConv(CC);
+ GuardB->setCallingConv(CC);
+ return eraseInstFromFunction(*II);
+ }
break;
}
}
call cc99 void(i1, ...) @llvm.experimental.guard( i1 %C )[ "deopt"() ]
ret void
}
+
+define void @test_guard_not_or(i1 %A, i1 %B) {
+; CHECK-LABEL: @test_guard_not_or(
+; CHECK-NEXT: %1 = xor i1 %A, true
+; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %1) [ "deopt"() ]
+; CHECK-NEXT: %2 = xor i1 %B, true
+; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %2) [ "deopt"() ]
+; CHECK-NEXT: ret void
+ %C = or i1 %A, %B
+ %D = xor i1 %C, true
+ call void(i1, ...) @llvm.experimental.guard( i1 %D )[ "deopt"() ]
+ ret void
+}
+
+define void @test_guard_not_or_non_default_cc(i1 %A, i1 %B) {
+; CHECK-LABEL: @test_guard_not_or_non_default_cc(
+; CHECK-NEXT: %1 = xor i1 %A, true
+; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %1) [ "deopt"() ]
+; CHECK-NEXT: %2 = xor i1 %B, true
+; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %2) [ "deopt"() ]
+; CHECK-NEXT: ret void
+ %C = or i1 %A, %B
+ %D = xor i1 %C, true
+ call cc99 void(i1, ...) @llvm.experimental.guard( i1 %D )[ "deopt"() ]
+ ret void
+}