diff options
Diffstat (limited to 'test/Transforms/InstCombine/icmp.ll')
-rw-r--r-- | test/Transforms/InstCombine/icmp.ll | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 6f657b190454..ed570da73c9e 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -2895,3 +2895,67 @@ define i1 @cmp_ult_rhs_dec(float %x, i32 %y) { %cmp = icmp ult i32 %conv, %dec ret i1 %cmp } + +define i1 @eq_add_constants(i32 %x, i32 %y) { +; CHECK-LABEL: @eq_add_constants( +; CHECK-NEXT: [[C:%.*]] = icmp eq i32 %x, %y +; CHECK-NEXT: ret i1 [[C]] +; + %A = add i32 %x, 5 + %B = add i32 %y, 5 + %C = icmp eq i32 %A, %B + ret i1 %C +} + +define i1 @eq_mul_constants(i32 %x, i32 %y) { +; CHECK-LABEL: @eq_mul_constants( +; CHECK-NEXT: [[C:%.*]] = icmp eq i32 %x, %y +; CHECK-NEXT: ret i1 [[C]] +; + %A = mul i32 %x, 5 + %B = mul i32 %y, 5 + %C = icmp eq i32 %A, %B + 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: [[C:%.*]] = icmp ne <2 x i32> %x, %y +; 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: [[TMP1:%.*]] = xor <2 x i32> %x, %y +; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i32> [[TMP1]], <i32 1073741823, i32 1073741823> +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[TMP2]], zeroinitializer +; 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 +} + |