From a8ac360a0c5796ec5560b3d4abaf511b1177c14d Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 24 May 2017 22:36:14 +0000 Subject: [InstCombine] add tests for icmp eq (mul X, C), (mul Y, C); NFC llvm-svn: 303816 --- llvm/test/Transforms/InstCombine/icmp.ll | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'llvm') diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 64242cffb03..9a952bad1da 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/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 +} + -- cgit v1.2.3