[llvm] 899af02 - [InstCombine] add tests for mul with sign-splat operand; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 13:19:36 PDT 2022


Author: Sanjay Patel
Date: 2022-05-26T16:19:15-04:00
New Revision: 899af021f48fa6f8c7acb51343faf7c75b1041c5

URL: https://github.com/llvm/llvm-project/commit/899af021f48fa6f8c7acb51343faf7c75b1041c5
DIFF: https://github.com/llvm/llvm-project/commit/899af021f48fa6f8c7acb51343faf7c75b1041c5.diff

LOG: [InstCombine] add tests for mul with sign-splat operand; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/mul.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll
index 43957a0e2a0a..47fd5fc87b10 100644
--- a/llvm/test/Transforms/InstCombine/mul.ll
+++ b/llvm/test/Transforms/InstCombine/mul.ll
@@ -462,6 +462,52 @@ define <2 x i32> @signbit_mul_vec_commute(<2 x i32> %a, <2 x i32> %b) {
   ret <2 x i32> %e
 }
 
+define i32 @signsplat_mul(i32 %x) {
+; CHECK-LABEL: @signsplat_mul(
+; CHECK-NEXT:    [[ASH:%.*]] = ashr i32 [[X:%.*]], 31
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i32 [[ASH]], 42
+; CHECK-NEXT:    ret i32 [[MUL]]
+;
+  %ash = ashr i32 %x, 31
+  %mul = mul i32 %ash, 42
+  ret i32 %mul
+}
+
+define <2 x i32> @signsplat_mul_vec(<2 x i32> %x) {
+; CHECK-LABEL: @signsplat_mul_vec(
+; CHECK-NEXT:    [[ASH:%.*]] = ashr <2 x i32> [[X:%.*]], <i32 31, i32 31>
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw <2 x i32> [[ASH]], <i32 42, i32 -3>
+; CHECK-NEXT:    ret <2 x i32> [[MUL]]
+;
+  %ash = ashr <2 x i32> %x, <i32 31, i32 31>
+  %mul = mul <2 x i32> %ash, <i32 42, i32 -3>
+  ret <2 x i32> %mul
+}
+
+define i32 @not_signsplat_mul(i32 %x) {
+; CHECK-LABEL: @not_signsplat_mul(
+; CHECK-NEXT:    [[ASH:%.*]] = ashr i32 [[X:%.*]], 30
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i32 [[ASH]], 42
+; CHECK-NEXT:    ret i32 [[MUL]]
+;
+  %ash = ashr i32 %x, 30
+  %mul = mul i32 %ash, 42
+  ret i32 %mul
+}
+
+define i32 @signsplat_mul_use(i32 %x) {
+; CHECK-LABEL: @signsplat_mul_use(
+; CHECK-NEXT:    [[ASH:%.*]] = ashr i32 [[X:%.*]], 31
+; CHECK-NEXT:    call void @use32(i32 [[ASH]])
+; CHECK-NEXT:    [[MUL:%.*]] = mul nsw i32 [[ASH]], -42
+; CHECK-NEXT:    ret i32 [[MUL]]
+;
+  %ash = ashr i32 %x, 31
+  call void @use32(i32 %ash)
+  %mul = mul i32 %ash, -42
+  ret i32 %mul
+}
+
 define i32 @test18(i32 %A, i32 %B) {
 ; CHECK-LABEL: @test18(
 ; CHECK-NEXT:    ret i32 0
@@ -1199,6 +1245,7 @@ define i32 @mulnot(i32 %a0) {
   %mul = mul i32 %add, -4
   ret i32 %mul
 }
+
 define i32 @mulnot_extrause(i32 %a0) {
 ; CHECK-LABEL: @mulnot_extrause(
 ; CHECK-NEXT:    [[NOT:%.*]] = xor i32 [[A0:%.*]], -1


        


More information about the llvm-commits mailing list