[llvm] 96f4aa6 - [InstCombine] add tests for low-mask-of-add; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 14:02:29 PST 2020
Author: Sanjay Patel
Date: 2020-11-12T17:02:14-05:00
New Revision: 96f4aa676567626b0299732158abc5a91a3defd2
URL: https://github.com/llvm/llvm-project/commit/96f4aa676567626b0299732158abc5a91a3defd2
DIFF: https://github.com/llvm/llvm-project/commit/96f4aa676567626b0299732158abc5a91a3defd2.diff
LOG: [InstCombine] add tests for low-mask-of-add; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/and.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll
index ad7c9a185be9..7bbc66990c43 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -1048,3 +1048,55 @@ define <2 x i32> @lowmask_sext_in_reg_splat(<2 x i32> %x, <2 x i32>* %p) {
%and = and <2 x i32> %r, <i32 4095, i32 4095>
ret <2 x i32> %and
}
+
+define i8 @lowmask_add(i8 %x) {
+; CHECK-LABEL: @lowmask_add(
+; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -64
+; CHECK-NEXT: call void @use8(i8 [[A]])
+; CHECK-NEXT: [[R:%.*]] = and i8 [[A]], 32
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %a = add i8 %x, -64 ; 0xc0
+ call void @use8(i8 %a)
+ %r = and i8 %a, 32 ; 0x20
+ ret i8 %r
+}
+
+define i8 @not_lowmask_add(i8 %x) {
+; CHECK-LABEL: @not_lowmask_add(
+; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -64
+; CHECK-NEXT: call void @use8(i8 [[A]])
+; CHECK-NEXT: [[R:%.*]] = and i8 [[A]], 64
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %a = add i8 %x, -64 ; 0xc0
+ call void @use8(i8 %a)
+ %r = and i8 %a, 64 ; 0x40
+ ret i8 %r
+}
+
+define i8 @not_lowmask_add2(i8 %x) {
+; CHECK-LABEL: @not_lowmask_add2(
+; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -96
+; CHECK-NEXT: call void @use8(i8 [[A]])
+; CHECK-NEXT: [[R:%.*]] = and i8 [[A]], 63
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %a = add i8 %x, -96 ; 0xe0
+ call void @use8(i8 %a)
+ %r = and i8 %a, 63 ; 0x3f
+ ret i8 %r
+}
+
+define <2 x i8> @lowmask_add_splat(<2 x i8> %x, <2 x i8>* %p) {
+; CHECK-LABEL: @lowmask_add_splat(
+; CHECK-NEXT: [[A:%.*]] = add <2 x i8> [[X:%.*]], <i8 -64, i8 -64>
+; CHECK-NEXT: store <2 x i8> [[A]], <2 x i8>* [[P:%.*]], align 2
+; CHECK-NEXT: [[R:%.*]] = and <2 x i8> [[A]], <i8 32, i8 32>
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %a = add <2 x i8> %x, <i8 -64, i8 -64> ; 0xc0
+ store <2 x i8> %a, <2 x i8>* %p
+ %r = and <2 x i8> %a, <i8 32, i8 32> ; 0x20
+ ret <2 x i8> %r
+}
More information about the llvm-commits
mailing list