[llvm] r303816 - [InstCombine] add tests for icmp eq (mul X, C), (mul Y, C); NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 15:36:15 PDT 2017


Author: spatel
Date: Wed May 24 17:36:14 2017
New Revision: 303816

URL: http://llvm.org/viewvc/llvm-project?rev=303816&view=rev
Log:
[InstCombine] add tests for icmp eq (mul X, C), (mul Y, C); NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/icmp.ll

Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=303816&r1=303815&r2=303816&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Wed May 24 17:36:14 2017
@@ -2918,3 +2918,46 @@ define i1 @eq_mul_constants(i32 %x, i32
   ret i1 %C
 }
 
+define <2 x i1> @eq_mul_constants_splat(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @eq_mul_constants_splat(
+; CHECK-NEXT:    [[A:%.*]] = mul <2 x i32> %x, <i32 5, i32 5>
+; CHECK-NEXT:    [[B:%.*]] = mul <2 x i32> %y, <i32 5, i32 5>
+; CHECK-NEXT:    [[C:%.*]] = icmp ne <2 x i32> [[A]], [[B]]
+; CHECK-NEXT:    ret <2 x i1> [[C]]
+;
+  %A = mul <2 x i32> %x, <i32 5, i32 5>
+  %B = mul <2 x i32> %y, <i32 5, i32 5>
+  %C = icmp ne <2 x i32> %A, %B
+  ret <2 x i1> %C
+}
+
+; If the multiply constant has any trailing zero bits, we get something completely different.
+; We mask off the high bits of each input and then convert:
+; (X&Z) == (Y&Z) -> (X^Y) & Z == 0
+
+define i1 @eq_mul_constants_with_tz(i32 %x, i32 %y) {
+; CHECK-LABEL: @eq_mul_constants_with_tz(
+; CHECK-NEXT:    [[TMP1:%.*]] = xor i32 %x, %y
+; CHECK-NEXT:    [[TMP2:%.*]] = and i32 [[TMP1]], 1073741823
+; CHECK-NEXT:    [[C:%.*]] = icmp ne i32 [[TMP2]], 0
+; CHECK-NEXT:    ret i1 [[C]]
+;
+  %A = mul i32 %x, 12
+  %B = mul i32 %y, 12
+  %C = icmp ne i32 %A, %B
+  ret i1 %C
+}
+
+define <2 x i1> @eq_mul_constants_with_tz_splat(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @eq_mul_constants_with_tz_splat(
+; CHECK-NEXT:    [[A:%.*]] = mul <2 x i32> %x, <i32 12, i32 12>
+; CHECK-NEXT:    [[B:%.*]] = mul <2 x i32> %y, <i32 12, i32 12>
+; CHECK-NEXT:    [[C:%.*]] = icmp eq <2 x i32> [[A]], [[B]]
+; CHECK-NEXT:    ret <2 x i1> [[C]]
+;
+  %A = mul <2 x i32> %x, <i32 12, i32 12>
+  %B = mul <2 x i32> %y, <i32 12, i32 12>
+  %C = icmp eq <2 x i32> %A, %B
+  ret <2 x i1> %C
+}
+




More information about the llvm-commits mailing list