summaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/InstCombine/sext.ll
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-09-10 15:25:31 -0700
committerGitHub <noreply@github.com>2025-09-10 15:25:31 -0700
commit1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch)
tree57f4b1f313c8cf74eed8819870f39c36ea263c68 /llvm/test/Transforms/InstCombine/sext.ll
parent898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff)
parentb8cefcb601ddaa18482555c4ff363c01a270c2fe (diff)
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'llvm/test/Transforms/InstCombine/sext.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/sext.ll38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/sext.ll b/llvm/test/Transforms/InstCombine/sext.ll
index ee3c52259f93..c72614d52603 100644
--- a/llvm/test/Transforms/InstCombine/sext.ll
+++ b/llvm/test/Transforms/InstCombine/sext.ll
@@ -423,3 +423,41 @@ define i64 @smear_set_bit_different_dest_type_wider_dst(i32 %x) {
%s = sext i8 %a to i64
ret i64 %s
}
+
+; Test known bits for (sext i8 x) * (sext i8 x)
+
+define i1 @sext_square_bit30(i8 noundef %x) {
+; CHECK-LABEL: @sext_square_bit30(
+; CHECK-NEXT: ret i1 false
+;
+ %sx = sext i8 %x to i32
+ %mul = mul nsw i32 %sx, %sx
+ %and = and i32 %mul, 1073741824 ; 1 << 30
+ %cmp = icmp ne i32 %and, 0
+ ret i1 %cmp
+}
+
+define i1 @sext_square_bit15(i8 noundef %x) {
+; CHECK-LABEL: @sext_square_bit15(
+; CHECK-NEXT: ret i1 false
+;
+ %sx = sext i8 %x to i32
+ %mul = mul nsw i32 %sx, %sx
+ %and = and i32 %mul, 32768 ; 1 << 15
+ %cmp = icmp ne i32 %and, 0
+ ret i1 %cmp
+}
+
+define i1 @sext_square_bit14(i8 noundef %x) {
+; CHECK-LABEL: @sext_square_bit14(
+; CHECK-NEXT: [[SX:%.*]] = sext i8 [[X:%.*]] to i32
+; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[SX]], [[SX]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp samesign ugt i32 [[MUL]], 16383
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %sx = sext i8 %x to i32
+ %mul = mul nsw i32 %sx, %sx
+ %and = and i32 %mul, 16384 ; 1 << 14
+ %cmp = icmp ne i32 %and, 0
+ ret i1 %cmp
+}