[llvm] r306508 - [InstCombine] Add test case demonstrating that we don't handle icmp eq (trunc (lshr(X, cst1)), cst->icmp (and X, mask), cst when the shift type is larger than 64-bits. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 23:42:48 PDT 2017


Author: ctopper
Date: Tue Jun 27 23:42:48 2017
New Revision: 306508

URL: http://llvm.org/viewvc/llvm-project?rev=306508&view=rev
Log:
[InstCombine] Add test case demonstrating that we don't handle icmp eq (trunc (lshr(X, cst1)), cst->icmp (and X, mask), cst when the shift type is larger than 64-bits. NFC

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

Modified: llvm/trunk/include/llvm/IR/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PatternMatch.h?rev=306508&r1=306507&r2=306508&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/IR/PatternMatch.h Tue Jun 27 23:42:48 2017
@@ -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;
       }

Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=306508&r1=306507&r2=306508&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Tue Jun 27 23:42:48 2017
@@ -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(




More information about the llvm-commits mailing list