From 7941a5200699e9f4f6e5d15f3ccdd8354fc41598 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 24 May 2017 22:36:14 +0000 Subject: [PATCH] [InstCombine] add tests for icmp eq (mul X, C), (mul Y, C); NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303816 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/icmp.ll | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 64242cffb03..9a952bad1da 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -2918,3 +2918,46 @@ define i1 @eq_mul_constants(i32 %x, i32 %y) { 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, +; CHECK-NEXT: [[B:%.*]] = mul <2 x i32> %y, +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[A]], [[B]] +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %A = mul <2 x i32> %x, + %B = mul <2 x i32> %y, + %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, +; CHECK-NEXT: [[B:%.*]] = mul <2 x i32> %y, +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[A]], [[B]] +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %A = mul <2 x i32> %x, + %B = mul <2 x i32> %y, + %C = icmp eq <2 x i32> %A, %B + ret <2 x i1> %C +} + -- 2.40.0