[llvm] d1dfa9f - [InstCombine] add tests for potential mul demanded bits fold; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 31 08:10:17 PST 2022


Author: Sanjay Patel
Date: 2022-01-31T11:10:10-05:00
New Revision: d1dfa9f78290d59046d2feeee270dcf7f64329c4

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

LOG: [InstCombine] add tests for potential mul demanded bits fold; NFC

This is discussed as an enhancement in D118539.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/mul-masked-bits.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/mul-masked-bits.ll b/llvm/test/Transforms/InstCombine/mul-masked-bits.ll
index 783674ab98676..6bd4eb8463d99 100644
--- a/llvm/test/Transforms/InstCombine/mul-masked-bits.ll
+++ b/llvm/test/Transforms/InstCombine/mul-masked-bits.ll
@@ -91,3 +91,25 @@ define i67 @one_demanded_low_bit(i67 %x) {
   %r = and i67 %m, 1
   ret i67 %r
 }
+
+define i33 @squared_one_demanded_low_bit(i33 %x) {
+; CHECK-LABEL: @squared_one_demanded_low_bit(
+; CHECK-NEXT:    [[MUL:%.*]] = mul i33 [[X:%.*]], [[X]]
+; CHECK-NEXT:    [[AND:%.*]] = and i33 [[MUL]], 1
+; CHECK-NEXT:    ret i33 [[AND]]
+;
+  %mul = mul i33 %x, %x
+  %and = and i33 %mul, 1
+  ret i33 %and
+}
+
+define <2 x i8> @squared_one_demanded_low_bit_splat(<2 x i8> %x) {
+; CHECK-LABEL: @squared_one_demanded_low_bit_splat(
+; CHECK-NEXT:    [[MUL:%.*]] = mul <2 x i8> [[X:%.*]], [[X]]
+; CHECK-NEXT:    [[AND:%.*]] = or <2 x i8> [[MUL]], <i8 -2, i8 -2>
+; CHECK-NEXT:    ret <2 x i8> [[AND]]
+;
+  %mul = mul <2 x i8> %x, %x
+  %and = or <2 x i8> %mul, <i8 254, i8 254>
+  ret <2 x i8> %and
+}


        


More information about the llvm-commits mailing list