[llvm] r293227 - Revert a couple of InstCombine/Guard checkins

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 26 15:38:12 PST 2017


Author: sanjoy
Date: Thu Jan 26 17:38:11 2017
New Revision: 293227

URL: http://llvm.org/viewvc/llvm-project?rev=293227&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/trunk/test/Transforms/InstCombine/call-guard.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=293227&r1=293226&r2=293227&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Thu Jan 26 17:38:11 2017
@@ -3010,35 +3010,6 @@ Instruction *InstCombiner::visitCallInst
     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;
   }
   }

Modified: llvm/trunk/test/Transforms/InstCombine/call-guard.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/call-guard.ll?rev=293227&r1=293226&r2=293227&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/call-guard.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/call-guard.ll Thu Jan 26 17:38:11 2017
@@ -28,49 +28,3 @@ define void @test_guard_adjacent_neg(i1
   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
-}




More information about the llvm-commits mailing list