[llvm] r292441 - [InstCombine] add tests for shl nsw with icmp eq/ne; NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 13:31:22 PST 2017


Author: spatel
Date: Wed Jan 18 15:31:21 2017
New Revision: 292441

URL: http://llvm.org/viewvc/llvm-project?rev=292441&view=rev
Log:
[InstCombine] add tests for shl nsw with icmp eq/ne; NFCI

These should be fixed with D28406.

Modified:
    llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll

Modified: llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll?rev=292441&r1=292440&r2=292441&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll Wed Jan 18 15:31:21 2017
@@ -354,3 +354,28 @@ define i1 @icmp_sle11(i8 %x) {
   ret i1 %cmp
 }
 
+; Some of the earlier sgt/sle tests are transformed to eq/ne, but try a couple
+; of those explicitly, so we know no intermediate transforms are necessary.
+
+define i1 @icmp_eq1(i8 %x) {
+; CHECK-LABEL: @icmp_eq1(
+; CHECK-NEXT:    [[SHL_MASK:%.*]] = and i8 %x, 127
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[SHL_MASK]], 6
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %shl = shl nsw i8 %x, 1
+  %cmp = icmp eq i8 %shl, 12
+  ret i1 %cmp
+}
+
+define i1 @icmp_ne1(i8 %x) {
+; CHECK-LABEL: @icmp_ne1(
+; CHECK-NEXT:    [[SHL_MASK:%.*]] = and i8 %x, 3
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 [[SHL_MASK]], 2
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %shl = shl nsw i8 %x, 6
+  %cmp = icmp ne i8 %shl, -128
+  ret i1 %cmp
+}
+




More information about the llvm-commits mailing list