[llvm] 142044a - [InstCombine] add tests for or with mul operand; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 29 12:03:58 PST 2021


Author: Sanjay Patel
Date: 2021-11-29T14:57:44-05:00
New Revision: 142044a0b52f767c11a74aee827c3cf598a68138

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

LOG: [InstCombine] add tests for or with mul operand; NFC

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll
index 4067dc487e810..962ad47d74edc 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -1441,3 +1441,72 @@ define <2 x i1> @cmp_overlap_splat(<2 x i5> %x) {
   %r = or <2 x i1> %isneg, %isnotneg
   ret <2 x i1> %r
 }
+
+define i32 @mul_no_common_bits(i32 %p1, i32 %p2) {
+; CHECK-LABEL: @mul_no_common_bits(
+; CHECK-NEXT:    [[X:%.*]] = and i32 [[P1:%.*]], 7
+; CHECK-NEXT:    [[Y:%.*]] = shl i32 [[P2:%.*]], 3
+; CHECK-NEXT:    [[M:%.*]] = mul i32 [[X]], [[Y]]
+; CHECK-NEXT:    [[R:%.*]] = or i32 [[M]], [[X]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %x = and i32 %p1, 7
+  %y = shl i32 %p2, 3
+  %m = mul i32 %x, %y
+  %r = or i32 %m, %x
+  ret i32 %r
+}
+
+define i32 @mul_no_common_bits_const_op(i32 %p) {
+; CHECK-LABEL: @mul_no_common_bits_const_op(
+; CHECK-NEXT:    [[X:%.*]] = and i32 [[P:%.*]], 7
+; CHECK-NEXT:    [[M:%.*]] = mul nuw nsw i32 [[X]], 24
+; CHECK-NEXT:    [[R:%.*]] = or i32 [[M]], [[X]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %x = and i32 %p, 7
+  %m = mul i32 %x, 24
+  %r = or i32 %m, %x
+  ret i32 %r
+}
+
+define <2 x i12> @mul_no_common_bits_commute(<2 x i12> %p) {
+; CHECK-LABEL: @mul_no_common_bits_commute(
+; CHECK-NEXT:    [[X:%.*]] = and <2 x i12> [[P:%.*]], <i12 1, i12 1>
+; CHECK-NEXT:    [[M:%.*]] = mul nuw nsw <2 x i12> [[X]], <i12 14, i12 16>
+; CHECK-NEXT:    [[R:%.*]] = or <2 x i12> [[X]], [[M]]
+; CHECK-NEXT:    ret <2 x i12> [[R]]
+;
+  %x = and <2 x i12> %p, <i12 1, i12 1>
+  %m = mul <2 x i12> %x, <i12 14, i12 16>
+  %r = or <2 x i12> %x, %m
+  ret <2 x i12> %r
+}
+
+define i32 @mul_no_common_bits_uses(i32 %p) {
+; CHECK-LABEL: @mul_no_common_bits_uses(
+; CHECK-NEXT:    [[X:%.*]] = and i32 [[P:%.*]], 7
+; CHECK-NEXT:    [[M:%.*]] = mul nuw nsw i32 [[X]], 24
+; CHECK-NEXT:    call void @use(i32 [[M]])
+; CHECK-NEXT:    [[R:%.*]] = or i32 [[M]], [[X]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %x = and i32 %p, 7
+  %m = mul i32 %x, 24
+  call void @use(i32 %m)
+  %r = or i32 %m, %x
+  ret i32 %r
+}
+
+define i32 @mul_common_bits(i32 %p) {
+; CHECK-LABEL: @mul_common_bits(
+; CHECK-NEXT:    [[X:%.*]] = and i32 [[P:%.*]], 7
+; CHECK-NEXT:    [[M:%.*]] = mul nuw nsw i32 [[X]], 12
+; CHECK-NEXT:    [[R:%.*]] = or i32 [[M]], [[X]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %x = and i32 %p, 7
+  %m = mul i32 %x, 12
+  %r = or i32 %m, %x
+  ret i32 %r
+}


        


More information about the llvm-commits mailing list