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

llvm-svn: 303816
This commit is contained in:
Sanjay Patel 2017-05-24 22:36:14 +00:00
parent 0e8521c05a
commit a8ac360a0c
1 changed files with 43 additions and 0 deletions

View File

@ -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, <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
}