Skip to content

Commit 5bb21ce

Browse files
committed
[InstCombine] add tests for icmp with mul operand; NFC
1 parent 4fa96b7 commit 5bb21ce

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

llvm/test/Transforms/InstCombine/icmp-mul.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,3 +857,31 @@ define i1 @mul_of_pow2_no_lz_other_op(i32 %x, i8 %y) {
857857
%r = icmp sgt i32 %m, 254
858858
ret i1 %r
859859
}
860+
861+
define i1 @splat_mul_known_lz(i32 %x) {
862+
; CHECK-LABEL: @splat_mul_known_lz(
863+
; CHECK-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i128
864+
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i128 [[Z]], 18446744078004518913
865+
; CHECK-NEXT: [[R:%.*]] = icmp ult i128 [[M]], 79228162514264337593543950336
866+
; CHECK-NEXT: ret i1 [[R]]
867+
;
868+
%z = zext i32 %x to i128
869+
%m = mul i128 %z, 18446744078004518913 ; 0x00000000_00000001_00000001_00000001
870+
%s = lshr i128 %m, 96
871+
%r = icmp eq i128 %s, 0
872+
ret i1 %r
873+
}
874+
875+
define i1 @splat_mul_unknown_lz(i32 %x) {
876+
; CHECK-LABEL: @splat_mul_unknown_lz(
877+
; CHECK-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i128
878+
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i128 [[Z]], 18446744078004518913
879+
; CHECK-NEXT: [[R:%.*]] = icmp ult i128 [[M]], 39614081257132168796771975168
880+
; CHECK-NEXT: ret i1 [[R]]
881+
;
882+
%z = zext i32 %x to i128
883+
%m = mul i128 %z, 18446744078004518913 ; 0x00000000_00000001_00000001_00000001
884+
%s = lshr i128 %m, 95
885+
%r = icmp eq i128 %s, 0
886+
ret i1 %r
887+
}

0 commit comments

Comments
 (0)