[llvm] 87e006b - [InstCombine] add tests for sub with masked bits; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 17:24:57 PST 2020
Author: Sanjay Patel
Date: 2020-11-12T20:10:28-05:00
New Revision: 87e006bedddda977813861b4e350fd1687d5a1db
URL: https://github.com/llvm/llvm-project/commit/87e006bedddda977813861b4e350fd1687d5a1db
DIFF: https://github.com/llvm/llvm-project/commit/87e006bedddda977813861b4e350fd1687d5a1db.diff
LOG: [InstCombine] add tests for sub with masked bits; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/sub.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll
index 98d8a9e6b5ca..d703004a2c00 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:%.*]], <i8 -64, i8 -64>
+; CHECK-NEXT: [[A2:%.*]] = and <2 x i8> [[X]], <i8 10, i8 10>
+; 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, <i8 192, i8 192> ; 0xc0
+ %a2 = and <2 x i8> %x, <i8 10, i8 10> ; 0x0a
+ store <2 x i8> %a2, <2 x i8>* %p
+ %r = sub <2 x i8> %a1, %a2
+ ret <2 x i8> %r
+}
More information about the llvm-commits
mailing list