Skip to content

Commit

Permalink
[InstCombine] add tests for icmp with mul operand; NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
rotateright committed Dec 19, 2021
1 parent 4fa96b7 commit 5bb21ce
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions llvm/test/Transforms/InstCombine/icmp-mul.ll
Expand Up @@ -857,3 +857,31 @@ define i1 @mul_of_pow2_no_lz_other_op(i32 %x, i8 %y) {
%r = icmp sgt i32 %m, 254
ret i1 %r
}

define i1 @splat_mul_known_lz(i32 %x) {
; CHECK-LABEL: @splat_mul_known_lz(
; CHECK-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i128
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i128 [[Z]], 18446744078004518913
; CHECK-NEXT: [[R:%.*]] = icmp ult i128 [[M]], 79228162514264337593543950336
; CHECK-NEXT: ret i1 [[R]]
;
%z = zext i32 %x to i128
%m = mul i128 %z, 18446744078004518913 ; 0x00000000_00000001_00000001_00000001
%s = lshr i128 %m, 96
%r = icmp eq i128 %s, 0
ret i1 %r
}

define i1 @splat_mul_unknown_lz(i32 %x) {
; CHECK-LABEL: @splat_mul_unknown_lz(
; CHECK-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i128
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i128 [[Z]], 18446744078004518913
; CHECK-NEXT: [[R:%.*]] = icmp ult i128 [[M]], 39614081257132168796771975168
; CHECK-NEXT: ret i1 [[R]]
;
%z = zext i32 %x to i128
%m = mul i128 %z, 18446744078004518913 ; 0x00000000_00000001_00000001_00000001
%s = lshr i128 %m, 95
%r = icmp eq i128 %s, 0
ret i1 %r
}

0 comments on commit 5bb21ce

Please sign in to comment.