1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mtriple=x86_64-unknown -basic-aa -slp-vectorizer -instcombine -S | FileCheck %s
3 ; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=slm -basic-aa -slp-vectorizer -instcombine -S | FileCheck %s
4 ; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=corei7-avx -basic-aa -slp-vectorizer -instcombine -S | FileCheck %s
5 ; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=core-avx2 -basic-aa -slp-vectorizer -instcombine -S | FileCheck %s
6 ; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=knl -basic-aa -slp-vectorizer -instcombine -S | FileCheck %s
7 ; RUN: opt < %s -mtriple=x86_64-unknown -mcpu=skx -basic-aa -slp-vectorizer -instcombine -S | FileCheck %s
9 define <8 x float> @sitofp_uitofp(<8 x i32> %a) {
10 ; CHECK-LABEL: @sitofp_uitofp(
11 ; CHECK-NEXT: [[TMP1:%.*]] = sitofp <8 x i32> [[A:%.*]] to <8 x float>
12 ; CHECK-NEXT: [[TMP2:%.*]] = uitofp <8 x i32> [[A]] to <8 x float>
13 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <8 x float> [[TMP1]], <8 x float> [[TMP2]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>
14 ; CHECK-NEXT: ret <8 x float> [[TMP3]]
16 %a0 = extractelement <8 x i32> %a, i32 0
17 %a1 = extractelement <8 x i32> %a, i32 1
18 %a2 = extractelement <8 x i32> %a, i32 2
19 %a3 = extractelement <8 x i32> %a, i32 3
20 %a4 = extractelement <8 x i32> %a, i32 4
21 %a5 = extractelement <8 x i32> %a, i32 5
22 %a6 = extractelement <8 x i32> %a, i32 6
23 %a7 = extractelement <8 x i32> %a, i32 7
24 %ab0 = sitofp i32 %a0 to float
25 %ab1 = sitofp i32 %a1 to float
26 %ab2 = sitofp i32 %a2 to float
27 %ab3 = sitofp i32 %a3 to float
28 %ab4 = uitofp i32 %a4 to float
29 %ab5 = uitofp i32 %a5 to float
30 %ab6 = uitofp i32 %a6 to float
31 %ab7 = uitofp i32 %a7 to float
32 %r0 = insertelement <8 x float> poison, float %ab0, i32 0
33 %r1 = insertelement <8 x float> %r0, float %ab1, i32 1
34 %r2 = insertelement <8 x float> %r1, float %ab2, i32 2
35 %r3 = insertelement <8 x float> %r2, float %ab3, i32 3
36 %r4 = insertelement <8 x float> %r3, float %ab4, i32 4
37 %r5 = insertelement <8 x float> %r4, float %ab5, i32 5
38 %r6 = insertelement <8 x float> %r5, float %ab6, i32 6
39 %r7 = insertelement <8 x float> %r6, float %ab7, i32 7
43 define <8 x i32> @fptosi_fptoui(<8 x float> %a) {
44 ; CHECK-LABEL: @fptosi_fptoui(
45 ; CHECK-NEXT: [[TMP1:%.*]] = fptosi <8 x float> [[A:%.*]] to <8 x i32>
46 ; CHECK-NEXT: [[TMP2:%.*]] = fptoui <8 x float> [[A]] to <8 x i32>
47 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <8 x i32> [[TMP1]], <8 x i32> [[TMP2]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>
48 ; CHECK-NEXT: ret <8 x i32> [[TMP3]]
50 %a0 = extractelement <8 x float> %a, i32 0
51 %a1 = extractelement <8 x float> %a, i32 1
52 %a2 = extractelement <8 x float> %a, i32 2
53 %a3 = extractelement <8 x float> %a, i32 3
54 %a4 = extractelement <8 x float> %a, i32 4
55 %a5 = extractelement <8 x float> %a, i32 5
56 %a6 = extractelement <8 x float> %a, i32 6
57 %a7 = extractelement <8 x float> %a, i32 7
58 %ab0 = fptosi float %a0 to i32
59 %ab1 = fptosi float %a1 to i32
60 %ab2 = fptosi float %a2 to i32
61 %ab3 = fptosi float %a3 to i32
62 %ab4 = fptoui float %a4 to i32
63 %ab5 = fptoui float %a5 to i32
64 %ab6 = fptoui float %a6 to i32
65 %ab7 = fptoui float %a7 to i32
66 %r0 = insertelement <8 x i32> poison, i32 %ab0, i32 0
67 %r1 = insertelement <8 x i32> %r0, i32 %ab1, i32 1
68 %r2 = insertelement <8 x i32> %r1, i32 %ab2, i32 2
69 %r3 = insertelement <8 x i32> %r2, i32 %ab3, i32 3
70 %r4 = insertelement <8 x i32> %r3, i32 %ab4, i32 4
71 %r5 = insertelement <8 x i32> %r4, i32 %ab5, i32 5
72 %r6 = insertelement <8 x i32> %r5, i32 %ab6, i32 6
73 %r7 = insertelement <8 x i32> %r6, i32 %ab7, i32 7
77 define <8 x float> @fneg_fabs(<8 x float> %a) {
78 ; CHECK-LABEL: @fneg_fabs(
79 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <8 x float> [[A:%.*]] to <8 x i32>
80 ; CHECK-NEXT: [[TMP2:%.*]] = xor <8 x i32> [[TMP1]], <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 poison, i32 poison, i32 poison, i32 poison>
81 ; CHECK-NEXT: [[TMP3:%.*]] = and <8 x i32> [[TMP1]], <i32 poison, i32 poison, i32 poison, i32 poison, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>
82 ; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <8 x i32> [[TMP2]], <8 x i32> [[TMP3]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>
83 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast <8 x i32> [[TMP4]] to <8 x float>
84 ; CHECK-NEXT: ret <8 x float> [[TMP5]]
86 %a0 = extractelement <8 x float> %a, i32 0
87 %a1 = extractelement <8 x float> %a, i32 1
88 %a2 = extractelement <8 x float> %a, i32 2
89 %a3 = extractelement <8 x float> %a, i32 3
90 %a4 = extractelement <8 x float> %a, i32 4
91 %a5 = extractelement <8 x float> %a, i32 5
92 %a6 = extractelement <8 x float> %a, i32 6
93 %a7 = extractelement <8 x float> %a, i32 7
94 %aa0 = bitcast float %a0 to i32
95 %aa1 = bitcast float %a1 to i32
96 %aa2 = bitcast float %a2 to i32
97 %aa3 = bitcast float %a3 to i32
98 %aa4 = bitcast float %a4 to i32
99 %aa5 = bitcast float %a5 to i32
100 %aa6 = bitcast float %a6 to i32
101 %aa7 = bitcast float %a7 to i32
102 %ab0 = xor i32 %aa0, -2147483648
103 %ab1 = xor i32 %aa1, -2147483648
104 %ab2 = xor i32 %aa2, -2147483648
105 %ab3 = xor i32 %aa3, -2147483648
106 %ab4 = and i32 %aa4, 2147483647
107 %ab5 = and i32 %aa5, 2147483647
108 %ab6 = and i32 %aa6, 2147483647
109 %ab7 = and i32 %aa7, 2147483647
110 %ac0 = bitcast i32 %ab0 to float
111 %ac1 = bitcast i32 %ab1 to float
112 %ac2 = bitcast i32 %ab2 to float
113 %ac3 = bitcast i32 %ab3 to float
114 %ac4 = bitcast i32 %ab4 to float
115 %ac5 = bitcast i32 %ab5 to float
116 %ac6 = bitcast i32 %ab6 to float
117 %ac7 = bitcast i32 %ab7 to float
118 %r0 = insertelement <8 x float> poison, float %ac0, i32 0
119 %r1 = insertelement <8 x float> %r0, float %ac1, i32 1
120 %r2 = insertelement <8 x float> %r1, float %ac2, i32 2
121 %r3 = insertelement <8 x float> %r2, float %ac3, i32 3
122 %r4 = insertelement <8 x float> %r3, float %ac4, i32 4
123 %r5 = insertelement <8 x float> %r4, float %ac5, i32 5
124 %r6 = insertelement <8 x float> %r5, float %ac6, i32 6
125 %r7 = insertelement <8 x float> %r6, float %ac7, i32 7
129 define <8 x i32> @sext_zext(<8 x i16> %a) {
130 ; CHECK-LABEL: @sext_zext(
131 ; CHECK-NEXT: [[TMP1:%.*]] = sext <8 x i16> [[A:%.*]] to <8 x i32>
132 ; CHECK-NEXT: [[TMP2:%.*]] = zext <8 x i16> [[A]] to <8 x i32>
133 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <8 x i32> [[TMP1]], <8 x i32> [[TMP2]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 12, i32 13, i32 14, i32 15>
134 ; CHECK-NEXT: ret <8 x i32> [[TMP3]]
136 %a0 = extractelement <8 x i16> %a, i32 0
137 %a1 = extractelement <8 x i16> %a, i32 1
138 %a2 = extractelement <8 x i16> %a, i32 2
139 %a3 = extractelement <8 x i16> %a, i32 3
140 %a4 = extractelement <8 x i16> %a, i32 4
141 %a5 = extractelement <8 x i16> %a, i32 5
142 %a6 = extractelement <8 x i16> %a, i32 6
143 %a7 = extractelement <8 x i16> %a, i32 7
144 %ab0 = sext i16 %a0 to i32
145 %ab1 = sext i16 %a1 to i32
146 %ab2 = sext i16 %a2 to i32
147 %ab3 = sext i16 %a3 to i32
148 %ab4 = zext i16 %a4 to i32
149 %ab5 = zext i16 %a5 to i32
150 %ab6 = zext i16 %a6 to i32
151 %ab7 = zext i16 %a7 to i32
152 %r0 = insertelement <8 x i32> poison, i32 %ab0, i32 0
153 %r1 = insertelement <8 x i32> %r0, i32 %ab1, i32 1
154 %r2 = insertelement <8 x i32> %r1, i32 %ab2, i32 2
155 %r3 = insertelement <8 x i32> %r2, i32 %ab3, i32 3
156 %r4 = insertelement <8 x i32> %r3, i32 %ab4, i32 4
157 %r5 = insertelement <8 x i32> %r4, i32 %ab5, i32 5
158 %r6 = insertelement <8 x i32> %r5, i32 %ab6, i32 6
159 %r7 = insertelement <8 x i32> %r6, i32 %ab7, i32 7
163 define <8 x float> @sitofp_4i32_8i16(<4 x i32> %a, <8 x i16> %b) {
164 ; CHECK-LABEL: @sitofp_4i32_8i16(
165 ; CHECK-NEXT: [[TMP1:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
166 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
167 ; CHECK-NEXT: [[TMP3:%.*]] = sitofp <4 x i16> [[TMP2]] to <4 x float>
168 ; CHECK-NEXT: [[R72:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> [[TMP3]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
169 ; CHECK-NEXT: ret <8 x float> [[R72]]
171 %a0 = extractelement <4 x i32> %a, i32 0
172 %a1 = extractelement <4 x i32> %a, i32 1
173 %a2 = extractelement <4 x i32> %a, i32 2
174 %a3 = extractelement <4 x i32> %a, i32 3
175 %b0 = extractelement <8 x i16> %b, i32 0
176 %b1 = extractelement <8 x i16> %b, i32 1
177 %b2 = extractelement <8 x i16> %b, i32 2
178 %b3 = extractelement <8 x i16> %b, i32 3
179 %ab0 = sitofp i32 %a0 to float
180 %ab1 = sitofp i32 %a1 to float
181 %ab2 = sitofp i32 %a2 to float
182 %ab3 = sitofp i32 %a3 to float
183 %ab4 = sitofp i16 %b0 to float
184 %ab5 = sitofp i16 %b1 to float
185 %ab6 = sitofp i16 %b2 to float
186 %ab7 = sitofp i16 %b3 to float
187 %r0 = insertelement <8 x float> poison, float %ab0, i32 0
188 %r1 = insertelement <8 x float> %r0, float %ab1, i32 1
189 %r2 = insertelement <8 x float> %r1, float %ab2, i32 2
190 %r3 = insertelement <8 x float> %r2, float %ab3, i32 3
191 %r4 = insertelement <8 x float> %r3, float %ab4, i32 4
192 %r5 = insertelement <8 x float> %r4, float %ab5, i32 5
193 %r6 = insertelement <8 x float> %r5, float %ab6, i32 6
194 %r7 = insertelement <8 x float> %r6, float %ab7, i32 7
198 ; Inspired by PR38154
199 define <8 x float> @sitofp_uitofp_4i32_8i16_16i8(<4 x i32> %a, <8 x i16> %b, <16 x i8> %c) {
200 ; CHECK-LABEL: @sitofp_uitofp_4i32_8i16_16i8(
201 ; CHECK-NEXT: [[TMP1:%.*]] = sitofp <4 x i32> [[A:%.*]] to <4 x float>
202 ; CHECK-NEXT: [[TMP2:%.*]] = uitofp <4 x i32> [[A]] to <4 x float>
203 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> [[TMP2]], <4 x i32> <i32 0, i32 1, i32 6, i32 7>
204 ; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> undef, <2 x i32> <i32 0, i32 1>
205 ; CHECK-NEXT: [[TMP5:%.*]] = sitofp <2 x i16> [[TMP4]] to <2 x float>
206 ; CHECK-NEXT: [[TMP6:%.*]] = uitofp <2 x i16> [[TMP4]] to <2 x float>
207 ; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <2 x float> [[TMP5]], <2 x float> [[TMP6]], <2 x i32> <i32 0, i32 3>
208 ; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <16 x i8> [[C:%.*]], <16 x i8> undef, <2 x i32> <i32 0, i32 1>
209 ; CHECK-NEXT: [[TMP9:%.*]] = sitofp <2 x i8> [[TMP8]] to <2 x float>
210 ; CHECK-NEXT: [[TMP10:%.*]] = uitofp <2 x i8> [[TMP8]] to <2 x float>
211 ; CHECK-NEXT: [[TMP11:%.*]] = shufflevector <2 x float> [[TMP9]], <2 x float> [[TMP10]], <2 x i32> <i32 0, i32 3>
212 ; CHECK-NEXT: [[R31:%.*]] = shufflevector <4 x float> [[TMP3]], <4 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
213 ; CHECK-NEXT: [[TMP12:%.*]] = shufflevector <2 x float> [[TMP7]], <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
214 ; CHECK-NEXT: [[R53:%.*]] = shufflevector <8 x float> [[R31]], <8 x float> [[TMP12]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 undef, i32 undef>
215 ; CHECK-NEXT: [[TMP13:%.*]] = shufflevector <2 x float> [[TMP11]], <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
216 ; CHECK-NEXT: [[R72:%.*]] = shufflevector <8 x float> [[R53]], <8 x float> [[TMP13]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 8, i32 9>
217 ; CHECK-NEXT: ret <8 x float> [[R72]]
219 %a0 = extractelement <4 x i32> %a, i32 0
220 %a1 = extractelement <4 x i32> %a, i32 1
221 %a2 = extractelement <4 x i32> %a, i32 2
222 %a3 = extractelement <4 x i32> %a, i32 3
223 %b0 = extractelement <8 x i16> %b, i32 0
224 %b1 = extractelement <8 x i16> %b, i32 1
225 %c0 = extractelement <16 x i8> %c, i32 0
226 %c1 = extractelement <16 x i8> %c, i32 1
227 %ab0 = sitofp i32 %a0 to float
228 %ab1 = sitofp i32 %a1 to float
229 %ab2 = uitofp i32 %a2 to float
230 %ab3 = uitofp i32 %a3 to float
231 %ab4 = sitofp i16 %b0 to float
232 %ab5 = uitofp i16 %b1 to float
233 %ab6 = sitofp i8 %c0 to float
234 %ab7 = uitofp i8 %c1 to float
235 %r0 = insertelement <8 x float> poison, float %ab0, i32 0
236 %r1 = insertelement <8 x float> %r0, float %ab1, i32 1
237 %r2 = insertelement <8 x float> %r1, float %ab2, i32 2
238 %r3 = insertelement <8 x float> %r2, float %ab3, i32 3
239 %r4 = insertelement <8 x float> %r3, float %ab4, i32 4
240 %r5 = insertelement <8 x float> %r4, float %ab5, i32 5
241 %r6 = insertelement <8 x float> %r5, float %ab6, i32 6
242 %r7 = insertelement <8 x float> %r6, float %ab7, i32 7