Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 4ad0fb1

Browse files
committed
[InstCombine][SSE] Tests showing missed opportunities to constant fold packss/packus
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292609 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 360cd34 commit 4ad0fb1

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

test/Transforms/InstCombine/x86-pack.ll

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,82 @@ define <32 x i8> @undef_packuswb_256() {
7777
ret <32 x i8> %1
7878
}
7979

80+
;
81+
; Constant Folding
82+
;
83+
84+
define <8 x i16> @fold_packssdw_128() {
85+
; CHECK-LABEL: @fold_packssdw_128(
86+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32> <i32 0, i32 -1, i32 65536, i32 -131072>, <4 x i32> zeroinitializer)
87+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
88+
;
89+
%1 = call <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32> <i32 0, i32 -1, i32 65536, i32 -131072>, <4 x i32> zeroinitializer)
90+
ret <8 x i16> %1
91+
}
92+
93+
define <8 x i16> @fold_packusdw_128() {
94+
; CHECK-LABEL: @fold_packusdw_128(
95+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> undef, <4 x i32> <i32 0, i32 -1, i32 32768, i32 65537>)
96+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
97+
;
98+
%1 = call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> undef, <4 x i32> <i32 0, i32 -1, i32 32768, i32 65537>)
99+
ret <8 x i16> %1
100+
}
101+
102+
define <16 x i8> @fold_packsswb_128() {
103+
; CHECK-LABEL: @fold_packsswb_128(
104+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> zeroinitializer, <8 x i16> undef)
105+
; CHECK-NEXT: ret <16 x i8> [[TMP1]]
106+
;
107+
%1 = call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> zeroinitializer, <8 x i16> undef)
108+
ret <16 x i8> %1
109+
}
110+
111+
define <16 x i8> @fold_packuswb_128() {
112+
; CHECK-LABEL: @fold_packuswb_128(
113+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16> <i16 0, i16 1, i16 -1, i16 255, i16 -1, i16 -32768, i16 -127, i16 15>, <8 x i16> <i16 -15, i16 127, i16 -32768, i16 1, i16 -255, i16 1, i16 -1, i16 0>)
114+
; CHECK-NEXT: ret <16 x i8> [[TMP1]]
115+
;
116+
%1 = call <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16> <i16 0, i16 1, i16 -1, i16 255, i16 65535, i16 -32768, i16 -127, i16 15>, <8 x i16> <i16 -15, i16 127, i16 32768, i16 -65535, i16 -255, i16 1, i16 -1, i16 0>)
117+
ret <16 x i8> %1
118+
}
119+
120+
define <16 x i16> @fold_packssdw_256() {
121+
; CHECK-LABEL: @fold_packssdw_256(
122+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.packssdw(<8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>, <8 x i32> undef)
123+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
124+
;
125+
%1 = call <16 x i16> @llvm.x86.avx2.packssdw(<8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>, <8 x i32> undef)
126+
ret <16 x i16> %1
127+
}
128+
129+
define <16 x i16> @fold_packusdw_256() {
130+
; CHECK-LABEL: @fold_packusdw_256(
131+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.packusdw(<8 x i32> <i32 0, i32 -256, i32 -65535, i32 65536, i32 127, i32 32768, i32 32767, i32 -32767>, <8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>)
132+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
133+
;
134+
%1 = call <16 x i16> @llvm.x86.avx2.packusdw(<8 x i32> <i32 0, i32 -256, i32 -65535, i32 65536, i32 127, i32 32768, i32 32767, i32 -32767>, <8 x i32> <i32 0, i32 256, i32 65535, i32 -65536, i32 -127, i32 -32768, i32 -32767, i32 32767>)
135+
ret <16 x i16> %1
136+
}
137+
138+
define <32 x i8> @fold_packsswb_256() {
139+
; CHECK-LABEL: @fold_packsswb_256(
140+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i8> @llvm.x86.avx2.packsswb(<16 x i16> undef, <16 x i16> zeroinitializer)
141+
; CHECK-NEXT: ret <32 x i8> [[TMP1]]
142+
;
143+
%1 = call <32 x i8> @llvm.x86.avx2.packsswb(<16 x i16> undef, <16 x i16> zeroinitializer)
144+
ret <32 x i8> %1
145+
}
146+
147+
define <32 x i8> @fold_packuswb_256() {
148+
; CHECK-LABEL: @fold_packuswb_256(
149+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i8> @llvm.x86.avx2.packuswb(<16 x i16> zeroinitializer, <16 x i16> <i16 0, i16 -127, i16 -128, i16 -32768, i16 0, i16 255, i16 256, i16 512, i16 -1, i16 1, i16 2, i16 4, i16 8, i16 16, i16 32, i16 64>)
150+
; CHECK-NEXT: ret <32 x i8> [[TMP1]]
151+
;
152+
%1 = call <32 x i8> @llvm.x86.avx2.packuswb(<16 x i16> zeroinitializer, <16 x i16> <i16 0, i16 -127, i16 -128, i16 -32768, i16 65536, i16 255, i16 256, i16 512, i16 -1, i16 1, i16 2, i16 4, i16 8, i16 16, i16 32, i16 64>)
153+
ret <32 x i8> %1
154+
}
155+
80156
;
81157
; Demanded Elts
82158
;

0 commit comments

Comments
 (0)