From: Sanjay Patel Date: Fri, 13 Nov 2020 00:44:13 +0000 (-0500) Subject: [InstCombine] add tests for sub with masked bits; NFC X-Git-Tag: llvmorg-13-init~6230 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87e006bedddda977813861b4e350fd1687d5a1db;p=platform%2Fupstream%2Fllvm.git [InstCombine] add tests for sub with masked bits; NFC --- diff --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll index 98d8a9e..d703004 100644 --- a/llvm/test/Transforms/InstCombine/sub.ll +++ b/llvm/test/Transforms/InstCombine/sub.ll @@ -1460,3 +1460,44 @@ define i8 @sub_add_sub_reassoc_use2(i8 %w, i8 %x, i8 %y, i8 %z) { %s2 = sub i8 %a, %z ret i8 %s2 } + +define i8 @sub_mask_lowbits(i8 %x) { +; CHECK-LABEL: @sub_mask_lowbits( +; CHECK-NEXT: [[A1:%.*]] = add i8 [[X:%.*]], -108 +; CHECK-NEXT: [[A2:%.*]] = and i8 [[X]], 3 +; CHECK-NEXT: [[R:%.*]] = sub i8 [[A1]], [[A2]] +; CHECK-NEXT: ret i8 [[R]] +; + %a1 = add i8 %x, 148 ; 0x94 + %a2 = and i8 %x, 3 + %r = sub i8 %a1, %a2 + ret i8 %r +} + +define i8 @sub_not_mask_lowbits(i8 %x) { +; CHECK-LABEL: @sub_not_mask_lowbits( +; CHECK-NEXT: [[A1:%.*]] = add i8 [[X:%.*]], 4 +; CHECK-NEXT: [[A2:%.*]] = and i8 [[X]], 7 +; CHECK-NEXT: [[R:%.*]] = sub i8 [[A1]], [[A2]] +; CHECK-NEXT: ret i8 [[R]] +; + %a1 = add i8 %x, 4 + %a2 = and i8 %x, 7 + %r = sub i8 %a1, %a2 + ret i8 %r +} + +define <2 x i8> @sub_mask_lowbits_splat_extra_use(<2 x i8> %x, <2 x i8>* %p) { +; CHECK-LABEL: @sub_mask_lowbits_splat_extra_use( +; CHECK-NEXT: [[A1:%.*]] = add <2 x i8> [[X:%.*]], +; CHECK-NEXT: [[A2:%.*]] = and <2 x i8> [[X]], +; CHECK-NEXT: store <2 x i8> [[A2]], <2 x i8>* [[P:%.*]], align 2 +; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[A1]], [[A2]] +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %a1 = add <2 x i8> %x, ; 0xc0 + %a2 = and <2 x i8> %x, ; 0x0a + store <2 x i8> %a2, <2 x i8>* %p + %r = sub <2 x i8> %a1, %a2 + ret <2 x i8> %r +}