]> granicus.if.org Git - llvm/commitdiff
[InstCombine] Add test case demonstrating that we don't handle icmp eq (trunc (lshr...
authorCraig Topper <craig.topper@gmail.com>
Wed, 28 Jun 2017 06:42:48 +0000 (06:42 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 28 Jun 2017 06:42:48 +0000 (06:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306508 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/PatternMatch.h
test/Transforms/InstCombine/icmp.ll

index 4015e445097c0e74e2f9eb77ded69ba03249649b..ae68b173c6b069120f75e8bd285f79dc2e1f477b 100644 (file)
@@ -379,6 +379,7 @@ struct bind_const_intval_ty {
   template <typename ITy> bool match(ITy *V) {
     if (const auto *CV = dyn_cast<ConstantInt>(V))
       if (CV->getBitWidth() <= 64) {
+        return false;
         VR = CV->getZExtValue();
         return true;
       }
index 12e8cc8f8a3a759ae7faed1b90a8c81d6fc9d1ca..0e2627b1768867d5e41f936bb91b5130eccf72fe 100644 (file)
@@ -762,6 +762,27 @@ define i1 @test52(i32 %x1) {
   ret i1 %A
 }
 
+; TODO we have a 64-bit or less restriction in the handling for this pattern. We should remove that and do the same thing we do above.
+define i1 @test52b(i128 %x1) {
+; CHECK-LABEL: @test52b(
+; CHECK-NEXT:    [[CONV:%.*]] = and i128 [[X1:%.*]], 255
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i128 [[CONV]], 127
+; CHECK-NEXT:    [[TMP2:%.*]] = lshr i128 [[X1]], 16
+; CHECK-NEXT:    [[TMP3:%.*]] = trunc i128 [[TMP2]] to i8
+; CHECK-NEXT:    [[CMP15:%.*]] = icmp eq i8 [[TMP3]], 76
+; CHECK-NEXT:    [[A:%.*]] = and i1 [[CMP]], [[CMP15]]
+; CHECK-NEXT:    ret i1 [[A]]
+;
+  %conv = and i128 %x1, 255
+  %cmp = icmp eq i128 %conv, 127
+  %tmp2 = lshr i128 %x1, 16
+  %tmp3 = trunc i128 %tmp2 to i8
+  %cmp15 = icmp eq i8 %tmp3, 76
+
+  %A = and i1 %cmp, %cmp15
+  ret i1 %A
+}
+
 ; PR9838
 define i1 @test53(i32 %a, i32 %b) {
 ; CHECK-LABEL: @test53(