From: Sanjay Patel Date: Mon, 29 Nov 2021 18:56:52 +0000 (-0500) Subject: [InstCombine] add tests for or with mul operand; NFC X-Git-Tag: upstream/15.0.7~24574 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=142044a0b52f767c11a74aee827c3cf598a68138;p=platform%2Fupstream%2Fllvm.git [InstCombine] add tests for or with mul operand; NFC --- diff --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll index 4067dc4..962ad47 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:%.*]], +; CHECK-NEXT: [[M:%.*]] = mul nuw nsw <2 x i12> [[X]], +; CHECK-NEXT: [[R:%.*]] = or <2 x i12> [[X]], [[M]] +; CHECK-NEXT: ret <2 x i12> [[R]] +; + %x = and <2 x i12> %p, + %m = mul <2 x i12> %x, + %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 +}