Skip to content

Commit 96f4aa6

Browse files
committed
[InstCombine] add tests for low-mask-of-add; NFC
1 parent 0c80b54 commit 96f4aa6

File tree

1 file changed

+52
-0
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+52
-0
lines changed

llvm/test/Transforms/InstCombine/and.ll

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,55 @@ define <2 x i32> @lowmask_sext_in_reg_splat(<2 x i32> %x, <2 x i32>* %p) {
10481048
%and = and <2 x i32> %r, <i32 4095, i32 4095>
10491049
ret <2 x i32> %and
10501050
}
1051+
1052+
define i8 @lowmask_add(i8 %x) {
1053+
; CHECK-LABEL: @lowmask_add(
1054+
; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -64
1055+
; CHECK-NEXT: call void @use8(i8 [[A]])
1056+
; CHECK-NEXT: [[R:%.*]] = and i8 [[A]], 32
1057+
; CHECK-NEXT: ret i8 [[R]]
1058+
;
1059+
%a = add i8 %x, -64 ; 0xc0
1060+
call void @use8(i8 %a)
1061+
%r = and i8 %a, 32 ; 0x20
1062+
ret i8 %r
1063+
}
1064+
1065+
define i8 @not_lowmask_add(i8 %x) {
1066+
; CHECK-LABEL: @not_lowmask_add(
1067+
; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -64
1068+
; CHECK-NEXT: call void @use8(i8 [[A]])
1069+
; CHECK-NEXT: [[R:%.*]] = and i8 [[A]], 64
1070+
; CHECK-NEXT: ret i8 [[R]]
1071+
;
1072+
%a = add i8 %x, -64 ; 0xc0
1073+
call void @use8(i8 %a)
1074+
%r = and i8 %a, 64 ; 0x40
1075+
ret i8 %r
1076+
}
1077+
1078+
define i8 @not_lowmask_add2(i8 %x) {
1079+
; CHECK-LABEL: @not_lowmask_add2(
1080+
; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], -96
1081+
; CHECK-NEXT: call void @use8(i8 [[A]])
1082+
; CHECK-NEXT: [[R:%.*]] = and i8 [[A]], 63
1083+
; CHECK-NEXT: ret i8 [[R]]
1084+
;
1085+
%a = add i8 %x, -96 ; 0xe0
1086+
call void @use8(i8 %a)
1087+
%r = and i8 %a, 63 ; 0x3f
1088+
ret i8 %r
1089+
}
1090+
1091+
define <2 x i8> @lowmask_add_splat(<2 x i8> %x, <2 x i8>* %p) {
1092+
; CHECK-LABEL: @lowmask_add_splat(
1093+
; CHECK-NEXT: [[A:%.*]] = add <2 x i8> [[X:%.*]], <i8 -64, i8 -64>
1094+
; CHECK-NEXT: store <2 x i8> [[A]], <2 x i8>* [[P:%.*]], align 2
1095+
; CHECK-NEXT: [[R:%.*]] = and <2 x i8> [[A]], <i8 32, i8 32>
1096+
; CHECK-NEXT: ret <2 x i8> [[R]]
1097+
;
1098+
%a = add <2 x i8> %x, <i8 -64, i8 -64> ; 0xc0
1099+
store <2 x i8> %a, <2 x i8>* %p
1100+
%r = and <2 x i8> %a, <i8 32, i8 32> ; 0x20
1101+
ret <2 x i8> %r
1102+
}

0 commit comments

Comments
 (0)