Revert a couple of InstCombine/Guard checkins

This change reverts:

r293061: "[InstCombine] Canonicalize guards for NOT OR condition"
r293058: "[InstCombine] Canonicalize guards for AND condition"

They miscompile cases like:

```
declare void @llvm.experimental.guard(i1, ...)

define void @test_guard_not_or(i1 %A, i1 %B) {
  %C = or i1 %A, %B
  %D = xor i1 %C, true
  call void(i1, ...) @llvm.experimental.guard(i1 %D, i32 20, i32 30)[ "deopt"() ]
  ret void
}
```

because they do transfer the `i32 20, i32 30` parameters to newly
created guard instructions.

llvm-svn: 293227
This commit is contained in:
Sanjoy Das 2017-01-26 23:38:11 +00:00
parent a0a1164ce4
commit 7516192a71
2 changed files with 0 additions and 75 deletions

View File

@ -3010,35 +3010,6 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
if (match(II->getNextNode(),
m_Intrinsic<Intrinsic::experimental_guard>(m_Specific(IIOperand))))
return eraseInstFromFunction(*II);
// Canonicalize guard(a && b) -> guard(a); guard(b);
// Note: New guard intrinsics created here are registered by
// the InstCombineIRInserter object.
Function *GuardIntrinsic = II->getCalledFunction();
Value *A, *B;
OperandBundleDef DeoptOB(*II->getOperandBundle(LLVMContext::OB_deopt));
if (match(IIOperand, m_And(m_Value(A), m_Value(B)))) {
CallInst *GuardA =
Builder->CreateCall(GuardIntrinsic, A, {DeoptOB}, II->getName());
CallInst *GuardB =
Builder->CreateCall(GuardIntrinsic, B, {DeoptOB}, II->getName());
auto CC = II->getCallingConv();
GuardA->setCallingConv(CC);
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;
}
}

View File

@ -28,49 +28,3 @@ define void @test_guard_adjacent_neg(i1 %A, i1 %B) {
call void(i1, ...) @llvm.experimental.guard( i1 %B )[ "deopt"() ]
ret void
}
define void @test_guard_and(i1 %A, i1 %B) {
; CHECK-LABEL: @test_guard_and(
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ]
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ]
; CHECK-NEXT: ret void
%C = and i1 %A, %B
call void(i1, ...) @llvm.experimental.guard( i1 %C )[ "deopt"() ]
ret void
}
define void @test_guard_and_non_default_cc(i1 %A, i1 %B) {
; CHECK-LABEL: @test_guard_and_non_default_cc(
; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ]
; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ]
; CHECK-NEXT: ret void
%C = and i1 %A, %B
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
}