[X86] Don't pass a scale value of 0 to scatter/gather intrinsics. This causes the...
[oota-llvm.git] / test / CodeGen / X86 / 3dnow-intrinsics.ll
1 ; RUN: llc < %s -march=x86 -mattr=+3dnow | FileCheck %s
2
3 define <8 x i8> @test_pavgusb(x86_mmx %a.coerce, x86_mmx %b.coerce) nounwind readnone {
4 ; CHECK: pavgusb
5 entry:
6   %0 = bitcast x86_mmx %a.coerce to <8 x i8>
7   %1 = bitcast x86_mmx %b.coerce to <8 x i8>
8   %2 = bitcast <8 x i8> %0 to x86_mmx
9   %3 = bitcast <8 x i8> %1 to x86_mmx
10   %4 = call x86_mmx @llvm.x86.3dnow.pavgusb(x86_mmx %2, x86_mmx %3)
11   %5 = bitcast x86_mmx %4 to <8 x i8>
12   ret <8 x i8> %5
13 }
14
15 declare x86_mmx @llvm.x86.3dnow.pavgusb(x86_mmx, x86_mmx) nounwind readnone
16
17 define <2 x i32> @test_pf2id(<2 x float> %a) nounwind readnone {
18 ; CHECK: pf2id
19 entry:
20   %0 = bitcast <2 x float> %a to x86_mmx
21   %1 = tail call x86_mmx @llvm.x86.3dnow.pf2id(x86_mmx %0)
22   %2 = bitcast x86_mmx %1 to <2 x i32>
23   ret <2 x i32> %2
24 }
25
26 declare x86_mmx @llvm.x86.3dnow.pf2id(x86_mmx) nounwind readnone
27
28 define <2 x float> @test_pfacc(<2 x float> %a, <2 x float> %b) nounwind readnone {
29 ; CHECK: pfacc
30 entry:
31   %0 = bitcast <2 x float> %a to x86_mmx
32   %1 = bitcast <2 x float> %b to x86_mmx
33   %2 = tail call x86_mmx @llvm.x86.3dnow.pfacc(x86_mmx %0, x86_mmx %1)
34   %3 = bitcast x86_mmx %2 to <2 x float>
35   ret <2 x float> %3
36 }
37
38 declare x86_mmx @llvm.x86.3dnow.pfacc(x86_mmx, x86_mmx) nounwind readnone
39
40 define <2 x float> @test_pfadd(<2 x float> %a, <2 x float> %b) nounwind readnone {
41 ; CHECK: pfadd
42 entry:
43   %0 = bitcast <2 x float> %a to x86_mmx
44   %1 = bitcast <2 x float> %b to x86_mmx
45   %2 = tail call x86_mmx @llvm.x86.3dnow.pfadd(x86_mmx %0, x86_mmx %1)
46   %3 = bitcast x86_mmx %2 to <2 x float>
47   ret <2 x float> %3
48 }
49
50 declare x86_mmx @llvm.x86.3dnow.pfadd(x86_mmx, x86_mmx) nounwind readnone
51
52 define <2 x i32> @test_pfcmpeq(<2 x float> %a, <2 x float> %b) nounwind readnone {
53 ; CHECK: pfcmpeq
54 entry:
55   %0 = bitcast <2 x float> %a to x86_mmx
56   %1 = bitcast <2 x float> %b to x86_mmx
57   %2 = tail call x86_mmx @llvm.x86.3dnow.pfcmpeq(x86_mmx %0, x86_mmx %1)
58   %3 = bitcast x86_mmx %2 to <2 x i32>
59   ret <2 x i32> %3
60 }
61
62 declare x86_mmx @llvm.x86.3dnow.pfcmpeq(x86_mmx, x86_mmx) nounwind readnone
63
64 define <2 x i32> @test_pfcmpge(<2 x float> %a, <2 x float> %b) nounwind readnone {
65 ; CHECK: pfcmpge
66 entry:
67   %0 = bitcast <2 x float> %a to x86_mmx
68   %1 = bitcast <2 x float> %b to x86_mmx
69   %2 = tail call x86_mmx @llvm.x86.3dnow.pfcmpge(x86_mmx %0, x86_mmx %1)
70   %3 = bitcast x86_mmx %2 to <2 x i32>
71   ret <2 x i32> %3
72 }
73
74 declare x86_mmx @llvm.x86.3dnow.pfcmpge(x86_mmx, x86_mmx) nounwind readnone
75
76 define <2 x i32> @test_pfcmpgt(<2 x float> %a, <2 x float> %b) nounwind readnone {
77 ; CHECK: pfcmpgt
78 entry:
79   %0 = bitcast <2 x float> %a to x86_mmx
80   %1 = bitcast <2 x float> %b to x86_mmx
81   %2 = tail call x86_mmx @llvm.x86.3dnow.pfcmpgt(x86_mmx %0, x86_mmx %1)
82   %3 = bitcast x86_mmx %2 to <2 x i32>
83   ret <2 x i32> %3
84 }
85
86 declare x86_mmx @llvm.x86.3dnow.pfcmpgt(x86_mmx, x86_mmx) nounwind readnone
87
88 define <2 x float> @test_pfmax(<2 x float> %a, <2 x float> %b) nounwind readnone {
89 ; CHECK: pfmax
90 entry:
91   %0 = bitcast <2 x float> %a to x86_mmx
92   %1 = bitcast <2 x float> %b to x86_mmx
93   %2 = tail call x86_mmx @llvm.x86.3dnow.pfmax(x86_mmx %0, x86_mmx %1)
94   %3 = bitcast x86_mmx %2 to <2 x float>
95   ret <2 x float> %3
96 }
97
98 declare x86_mmx @llvm.x86.3dnow.pfmax(x86_mmx, x86_mmx) nounwind readnone
99
100 define <2 x float> @test_pfmin(<2 x float> %a, <2 x float> %b) nounwind readnone {
101 ; CHECK: pfmin
102 entry:
103   %0 = bitcast <2 x float> %a to x86_mmx
104   %1 = bitcast <2 x float> %b to x86_mmx
105   %2 = tail call x86_mmx @llvm.x86.3dnow.pfmin(x86_mmx %0, x86_mmx %1)
106   %3 = bitcast x86_mmx %2 to <2 x float>
107   ret <2 x float> %3
108 }
109
110 declare x86_mmx @llvm.x86.3dnow.pfmin(x86_mmx, x86_mmx) nounwind readnone
111
112 define <2 x float> @test_pfmul(<2 x float> %a, <2 x float> %b) nounwind readnone {
113 ; CHECK: pfmul
114 entry:
115   %0 = bitcast <2 x float> %a to x86_mmx
116   %1 = bitcast <2 x float> %b to x86_mmx
117   %2 = tail call x86_mmx @llvm.x86.3dnow.pfmul(x86_mmx %0, x86_mmx %1)
118   %3 = bitcast x86_mmx %2 to <2 x float>
119   ret <2 x float> %3
120 }
121
122 declare x86_mmx @llvm.x86.3dnow.pfmul(x86_mmx, x86_mmx) nounwind readnone
123
124 define <2 x float> @test_pfrcp(<2 x float> %a) nounwind readnone {
125 ; CHECK: pfrcp
126 entry:
127   %0 = bitcast <2 x float> %a to x86_mmx
128   %1 = tail call x86_mmx @llvm.x86.3dnow.pfrcp(x86_mmx %0)
129   %2 = bitcast x86_mmx %1 to <2 x float>
130   ret <2 x float> %2
131 }
132
133 declare x86_mmx @llvm.x86.3dnow.pfrcp(x86_mmx) nounwind readnone
134
135 define <2 x float> @test_pfrcpit1(<2 x float> %a, <2 x float> %b) nounwind readnone {
136 ; CHECK: pfrcpit1
137 entry:
138   %0 = bitcast <2 x float> %a to x86_mmx
139   %1 = bitcast <2 x float> %b to x86_mmx
140   %2 = tail call x86_mmx @llvm.x86.3dnow.pfrcpit1(x86_mmx %0, x86_mmx %1)
141   %3 = bitcast x86_mmx %2 to <2 x float>
142   ret <2 x float> %3
143 }
144
145 declare x86_mmx @llvm.x86.3dnow.pfrcpit1(x86_mmx, x86_mmx) nounwind readnone
146
147 define <2 x float> @test_pfrcpit2(<2 x float> %a, <2 x float> %b) nounwind readnone {
148 ; CHECK: pfrcpit2
149 entry:
150   %0 = bitcast <2 x float> %a to x86_mmx
151   %1 = bitcast <2 x float> %b to x86_mmx
152   %2 = tail call x86_mmx @llvm.x86.3dnow.pfrcpit2(x86_mmx %0, x86_mmx %1)
153   %3 = bitcast x86_mmx %2 to <2 x float>
154   ret <2 x float> %3
155 }
156
157 declare x86_mmx @llvm.x86.3dnow.pfrcpit2(x86_mmx, x86_mmx) nounwind readnone
158
159 define <2 x float> @test_pfrsqrt(<2 x float> %a) nounwind readnone {
160 ; CHECK: pfrsqrt
161 entry:
162   %0 = bitcast <2 x float> %a to x86_mmx
163   %1 = tail call x86_mmx @llvm.x86.3dnow.pfrsqrt(x86_mmx %0)
164   %2 = bitcast x86_mmx %1 to <2 x float>
165   ret <2 x float> %2
166 }
167
168 declare x86_mmx @llvm.x86.3dnow.pfrsqrt(x86_mmx) nounwind readnone
169
170 define <2 x float> @test_pfrsqit1(<2 x float> %a, <2 x float> %b) nounwind readnone {
171 ; CHECK: pfrsqit1
172 entry:
173   %0 = bitcast <2 x float> %a to x86_mmx
174   %1 = bitcast <2 x float> %b to x86_mmx
175   %2 = tail call x86_mmx @llvm.x86.3dnow.pfrsqit1(x86_mmx %0, x86_mmx %1)
176   %3 = bitcast x86_mmx %2 to <2 x float>
177   ret <2 x float> %3
178 }
179
180 declare x86_mmx @llvm.x86.3dnow.pfrsqit1(x86_mmx, x86_mmx) nounwind readnone
181
182 define <2 x float> @test_pfsub(<2 x float> %a, <2 x float> %b) nounwind readnone {
183 ; CHECK: pfsub
184 entry:
185   %0 = bitcast <2 x float> %a to x86_mmx
186   %1 = bitcast <2 x float> %b to x86_mmx
187   %2 = tail call x86_mmx @llvm.x86.3dnow.pfsub(x86_mmx %0, x86_mmx %1)
188   %3 = bitcast x86_mmx %2 to <2 x float>
189   ret <2 x float> %3
190 }
191
192 declare x86_mmx @llvm.x86.3dnow.pfsub(x86_mmx, x86_mmx) nounwind readnone
193
194 define <2 x float> @test_pfsubr(<2 x float> %a, <2 x float> %b) nounwind readnone {
195 ; CHECK: pfsubr
196 entry:
197   %0 = bitcast <2 x float> %a to x86_mmx
198   %1 = bitcast <2 x float> %b to x86_mmx
199   %2 = tail call x86_mmx @llvm.x86.3dnow.pfsubr(x86_mmx %0, x86_mmx %1)
200   %3 = bitcast x86_mmx %2 to <2 x float>
201   ret <2 x float> %3
202 }
203
204 declare x86_mmx @llvm.x86.3dnow.pfsubr(x86_mmx, x86_mmx) nounwind readnone
205
206 define <2 x float> @test_pi2fd(x86_mmx %a.coerce) nounwind readnone {
207 ; CHECK: pi2fd
208 entry:
209   %0 = bitcast x86_mmx %a.coerce to <2 x i32>
210   %1 = bitcast <2 x i32> %0 to x86_mmx
211   %2 = call x86_mmx @llvm.x86.3dnow.pi2fd(x86_mmx %1)
212   %3 = bitcast x86_mmx %2 to <2 x float>
213   ret <2 x float> %3
214 }
215
216 declare x86_mmx @llvm.x86.3dnow.pi2fd(x86_mmx) nounwind readnone
217
218 define <4 x i16> @test_pmulhrw(x86_mmx %a.coerce, x86_mmx %b.coerce) nounwind readnone {
219 ; CHECK: pmulhrw
220 entry:
221   %0 = bitcast x86_mmx %a.coerce to <4 x i16>
222   %1 = bitcast x86_mmx %b.coerce to <4 x i16>
223   %2 = bitcast <4 x i16> %0 to x86_mmx
224   %3 = bitcast <4 x i16> %1 to x86_mmx
225   %4 = call x86_mmx @llvm.x86.3dnow.pmulhrw(x86_mmx %2, x86_mmx %3)
226   %5 = bitcast x86_mmx %4 to <4 x i16>
227   ret <4 x i16> %5
228 }
229
230 declare x86_mmx @llvm.x86.3dnow.pmulhrw(x86_mmx, x86_mmx) nounwind readnone
231
232 define <2 x i32> @test_pf2iw(<2 x float> %a) nounwind readnone {
233 ; CHECK: pf2iw
234 entry:
235   %0 = bitcast <2 x float> %a to x86_mmx
236   %1 = tail call x86_mmx @llvm.x86.3dnowa.pf2iw(x86_mmx %0)
237   %2 = bitcast x86_mmx %1 to <2 x i32>
238   ret <2 x i32> %2
239 }
240
241 declare x86_mmx @llvm.x86.3dnowa.pf2iw(x86_mmx) nounwind readnone
242
243 define <2 x float> @test_pfnacc(<2 x float> %a, <2 x float> %b) nounwind readnone {
244 ; CHECK: pfnacc
245 entry:
246   %0 = bitcast <2 x float> %a to x86_mmx
247   %1 = bitcast <2 x float> %b to x86_mmx
248   %2 = tail call x86_mmx @llvm.x86.3dnowa.pfnacc(x86_mmx %0, x86_mmx %1)
249   %3 = bitcast x86_mmx %2 to <2 x float>
250   ret <2 x float> %3
251 }
252
253 declare x86_mmx @llvm.x86.3dnowa.pfnacc(x86_mmx, x86_mmx) nounwind readnone
254
255 define <2 x float> @test_pfpnacc(<2 x float> %a, <2 x float> %b) nounwind readnone {
256 ; CHECK: pfpnacc
257 entry:
258   %0 = bitcast <2 x float> %a to x86_mmx
259   %1 = bitcast <2 x float> %b to x86_mmx
260   %2 = tail call x86_mmx @llvm.x86.3dnowa.pfpnacc(x86_mmx %0, x86_mmx %1)
261   %3 = bitcast x86_mmx %2 to <2 x float>
262   ret <2 x float> %3
263 }
264
265 declare x86_mmx @llvm.x86.3dnowa.pfpnacc(x86_mmx, x86_mmx) nounwind readnone
266
267 define <2 x float> @test_pi2fw(x86_mmx %a.coerce) nounwind readnone {
268 ; CHECK: pi2fw
269 entry:
270   %0 = bitcast x86_mmx %a.coerce to <2 x i32>
271   %1 = bitcast <2 x i32> %0 to x86_mmx
272   %2 = call x86_mmx @llvm.x86.3dnowa.pi2fw(x86_mmx %1)
273   %3 = bitcast x86_mmx %2 to <2 x float>
274   ret <2 x float> %3
275 }
276
277 declare x86_mmx @llvm.x86.3dnowa.pi2fw(x86_mmx) nounwind readnone
278
279 define <2 x float> @test_pswapdsf(<2 x float> %a) nounwind readnone {
280 ; CHECK: pswapd {{.*#+}} mm0 = mem[1,0]
281 entry:
282   %0 = bitcast <2 x float> %a to x86_mmx
283   %1 = tail call x86_mmx @llvm.x86.3dnowa.pswapd(x86_mmx %0)
284   %2 = bitcast x86_mmx %1 to <2 x float>
285   ret <2 x float> %2
286 }
287
288 define <2 x i32> @test_pswapdsi(<2 x i32> %a) nounwind readnone {
289 ; CHECK: pswapd {{.*#+}} mm0 = mem[1,0]
290 entry:
291   %0 = bitcast <2 x i32> %a to x86_mmx
292   %1 = tail call x86_mmx @llvm.x86.3dnowa.pswapd(x86_mmx %0)
293   %2 = bitcast x86_mmx %1 to <2 x i32>
294   ret <2 x i32> %2
295 }
296
297 declare x86_mmx @llvm.x86.3dnowa.pswapd(x86_mmx) nounwind readnone