xref: /llvm-project/llvm/test/CodeGen/WebAssembly/simd-bitcasts.ll (revision 122b0220fd45ee71acda912b0b712bb8edb6ba46)
1*27748363SThomas Lively; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
264a39a1cSThomas Lively; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals | FileCheck %s --check-prefixes CHECK,NO-SIMD128
3720fbf55SThomas Lively
4720fbf55SThomas Lively; Test that bitcasts between vector types are lowered to zero instructions
5720fbf55SThomas Lively
6720fbf55SThomas Livelytarget triple = "wasm32-unknown-unknown"
7720fbf55SThomas Lively
8720fbf55SThomas Lively; CHECK-LABEL: v16i8_to_v16i8:
9720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
10720fbf55SThomas Lively; SIMD128: return $0
11720fbf55SThomas Livelydefine <16 x i8> @v16i8_to_v16i8(<16 x i8> %v) {
12720fbf55SThomas Lively  %res = bitcast <16 x i8> %v to <16 x i8>
13720fbf55SThomas Lively  ret <16 x i8> %res
14720fbf55SThomas Lively}
15720fbf55SThomas Lively
16720fbf55SThomas Lively; CHECK-LABEL: v16i8_to_v8i16:
17720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
18720fbf55SThomas Lively; SIMD128: return $0
19720fbf55SThomas Livelydefine <8 x i16> @v16i8_to_v8i16(<16 x i8> %v) {
20720fbf55SThomas Lively  %res = bitcast <16 x i8> %v to <8 x i16>
21720fbf55SThomas Lively  ret <8 x i16> %res
22720fbf55SThomas Lively}
23720fbf55SThomas Lively
24720fbf55SThomas Lively; CHECK-LABEL: v16i8_to_v4i32:
25720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
26720fbf55SThomas Lively; SIMD128: return $0
27720fbf55SThomas Livelydefine <4 x i32> @v16i8_to_v4i32(<16 x i8> %v) {
28720fbf55SThomas Lively  %res = bitcast <16 x i8> %v to <4 x i32>
29720fbf55SThomas Lively  ret <4 x i32> %res
30720fbf55SThomas Lively}
31720fbf55SThomas Lively
32720fbf55SThomas Lively; CHECK-LABEL: v16i8_to_v2i64:
33720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
34720fbf55SThomas Lively; SIMD128: return $0
35720fbf55SThomas Livelydefine <2 x i64> @v16i8_to_v2i64(<16 x i8> %v) {
36720fbf55SThomas Lively  %res = bitcast <16 x i8> %v to <2 x i64>
37720fbf55SThomas Lively  ret <2 x i64> %res
38720fbf55SThomas Lively}
39720fbf55SThomas Lively
40720fbf55SThomas Lively; CHECK-LABEL: v16i8_to_v4f32:
41720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
42720fbf55SThomas Lively; SIMD128: return $0
43720fbf55SThomas Livelydefine <4 x float> @v16i8_to_v4f32(<16 x i8> %v) {
44720fbf55SThomas Lively  %res = bitcast <16 x i8> %v to <4 x float>
45720fbf55SThomas Lively  ret <4 x float> %res
46720fbf55SThomas Lively}
47720fbf55SThomas Lively
48720fbf55SThomas Lively; CHECK-LABEL: v16i8_to_v2f64:
49720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
50720fbf55SThomas Lively; SIMD128: return $0
51720fbf55SThomas Livelydefine <2 x double> @v16i8_to_v2f64(<16 x i8> %v) {
52720fbf55SThomas Lively  %res = bitcast <16 x i8> %v to <2 x double>
53720fbf55SThomas Lively  ret <2 x double> %res
54720fbf55SThomas Lively}
55720fbf55SThomas Lively
56720fbf55SThomas Lively; CHECK-LABEL: v8i16_to_v16i8:
57720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
58720fbf55SThomas Lively; SIMD128: return $0
59720fbf55SThomas Livelydefine <16 x i8> @v8i16_to_v16i8(<8 x i16> %v) {
60720fbf55SThomas Lively  %res = bitcast <8 x i16> %v to <16 x i8>
61720fbf55SThomas Lively  ret <16 x i8> %res
62720fbf55SThomas Lively}
63720fbf55SThomas Lively
64720fbf55SThomas Lively; CHECK-LABEL: v8i16_to_v8i16:
65720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
66720fbf55SThomas Lively; SIMD128: return $0
67720fbf55SThomas Livelydefine <8 x i16> @v8i16_to_v8i16(<8 x i16> %v) {
68720fbf55SThomas Lively  %res = bitcast <8 x i16> %v to <8 x i16>
69720fbf55SThomas Lively  ret <8 x i16> %res
70720fbf55SThomas Lively}
71720fbf55SThomas Lively
72720fbf55SThomas Lively; CHECK-LABEL: v8i16_to_v4i32:
73720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
74720fbf55SThomas Lively; SIMD128: return $0
75720fbf55SThomas Livelydefine <4 x i32> @v8i16_to_v4i32(<8 x i16> %v) {
76720fbf55SThomas Lively  %res = bitcast <8 x i16> %v to <4 x i32>
77720fbf55SThomas Lively  ret <4 x i32> %res
78720fbf55SThomas Lively}
79720fbf55SThomas Lively
80720fbf55SThomas Lively; CHECK-LABEL: v8i16_to_v2i64:
81720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
82720fbf55SThomas Lively; SIMD128: return $0
83720fbf55SThomas Livelydefine <2 x i64> @v8i16_to_v2i64(<8 x i16> %v) {
84720fbf55SThomas Lively  %res = bitcast <8 x i16> %v to <2 x i64>
85720fbf55SThomas Lively  ret <2 x i64> %res
86720fbf55SThomas Lively}
87720fbf55SThomas Lively
88720fbf55SThomas Lively; CHECK-LABEL: v8i16_to_v4f32:
89720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
90720fbf55SThomas Lively; SIMD128: return $0
91720fbf55SThomas Livelydefine <4 x float> @v8i16_to_v4f32(<8 x i16> %v) {
92720fbf55SThomas Lively  %res = bitcast <8 x i16> %v to <4 x float>
93720fbf55SThomas Lively  ret <4 x float> %res
94720fbf55SThomas Lively}
95720fbf55SThomas Lively
96720fbf55SThomas Lively; CHECK-LABEL: v8i16_to_v2f64:
97720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
98720fbf55SThomas Lively; SIMD128: return $0
99720fbf55SThomas Livelydefine <2 x double> @v8i16_to_v2f64(<8 x i16> %v) {
100720fbf55SThomas Lively  %res = bitcast <8 x i16> %v to <2 x double>
101720fbf55SThomas Lively  ret <2 x double> %res
102720fbf55SThomas Lively}
103720fbf55SThomas Lively
104720fbf55SThomas Lively; CHECK-LABEL: v4i32_to_v16i8:
105720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
106720fbf55SThomas Lively; SIMD128: return $0
107720fbf55SThomas Livelydefine <16 x i8> @v4i32_to_v16i8(<4 x i32> %v) {
108720fbf55SThomas Lively  %res = bitcast <4 x i32> %v to <16 x i8>
109720fbf55SThomas Lively  ret <16 x i8> %res
110720fbf55SThomas Lively}
111720fbf55SThomas Lively
112720fbf55SThomas Lively; CHECK-LABEL: v4i32_to_v8i16:
113720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
114720fbf55SThomas Lively; SIMD128: return $0
115720fbf55SThomas Livelydefine <8 x i16> @v4i32_to_v8i16(<4 x i32> %v) {
116720fbf55SThomas Lively  %res = bitcast <4 x i32> %v to <8 x i16>
117720fbf55SThomas Lively  ret <8 x i16> %res
118720fbf55SThomas Lively}
119720fbf55SThomas Lively
120720fbf55SThomas Lively; CHECK-LABEL: v4i32_to_v4i32:
121720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
122720fbf55SThomas Lively; SIMD128: return $0
123720fbf55SThomas Livelydefine <4 x i32> @v4i32_to_v4i32(<4 x i32> %v) {
124720fbf55SThomas Lively  %res = bitcast <4 x i32> %v to <4 x i32>
125720fbf55SThomas Lively  ret <4 x i32> %res
126720fbf55SThomas Lively}
127720fbf55SThomas Lively
128720fbf55SThomas Lively; CHECK-LABEL: v4i32_to_v2i64:
129720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
130720fbf55SThomas Lively; SIMD128: return $0
131720fbf55SThomas Livelydefine <2 x i64> @v4i32_to_v2i64(<4 x i32> %v) {
132720fbf55SThomas Lively  %res = bitcast <4 x i32> %v to <2 x i64>
133720fbf55SThomas Lively  ret <2 x i64> %res
134720fbf55SThomas Lively}
135720fbf55SThomas Lively
136720fbf55SThomas Lively; CHECK-LABEL: v4i32_to_v4f32:
137720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
138720fbf55SThomas Lively; SIMD128: return $0
139720fbf55SThomas Livelydefine <4 x float> @v4i32_to_v4f32(<4 x i32> %v) {
140720fbf55SThomas Lively  %res = bitcast <4 x i32> %v to <4 x float>
141720fbf55SThomas Lively  ret <4 x float> %res
142720fbf55SThomas Lively}
143720fbf55SThomas Lively
144720fbf55SThomas Lively; CHECK-LABEL: v4i32_to_v2f64:
145720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
146720fbf55SThomas Lively; SIMD128: return $0
147720fbf55SThomas Livelydefine <2 x double> @v4i32_to_v2f64(<4 x i32> %v) {
148720fbf55SThomas Lively  %res = bitcast <4 x i32> %v to <2 x double>
149720fbf55SThomas Lively  ret <2 x double> %res
150720fbf55SThomas Lively}
151720fbf55SThomas Lively
152720fbf55SThomas Lively; CHECK-LABEL: v2i64_to_v16i8:
153720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
154720fbf55SThomas Lively; SIMD128: return $0
155720fbf55SThomas Livelydefine <16 x i8> @v2i64_to_v16i8(<2 x i64> %v) {
156720fbf55SThomas Lively  %res = bitcast <2 x i64> %v to <16 x i8>
157720fbf55SThomas Lively  ret <16 x i8> %res
158720fbf55SThomas Lively}
159720fbf55SThomas Lively
160720fbf55SThomas Lively; CHECK-LABEL: v2i64_to_v8i16:
161720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
162720fbf55SThomas Lively; SIMD128: return $0
163720fbf55SThomas Livelydefine <8 x i16> @v2i64_to_v8i16(<2 x i64> %v) {
164720fbf55SThomas Lively  %res = bitcast <2 x i64> %v to <8 x i16>
165720fbf55SThomas Lively  ret <8 x i16> %res
166720fbf55SThomas Lively}
167720fbf55SThomas Lively
168720fbf55SThomas Lively; CHECK-LABEL: v2i64_to_v4i32:
169720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
170720fbf55SThomas Lively; SIMD128: return $0
171720fbf55SThomas Livelydefine <4 x i32> @v2i64_to_v4i32(<2 x i64> %v) {
172720fbf55SThomas Lively  %res = bitcast <2 x i64> %v to <4 x i32>
173720fbf55SThomas Lively  ret <4 x i32> %res
174720fbf55SThomas Lively}
175720fbf55SThomas Lively
176720fbf55SThomas Lively; CHECK-LABEL: v2i64_to_v2i64:
177720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
178720fbf55SThomas Lively; SIMD128: return $0
179720fbf55SThomas Livelydefine <2 x i64> @v2i64_to_v2i64(<2 x i64> %v) {
180720fbf55SThomas Lively  %res = bitcast <2 x i64> %v to <2 x i64>
181720fbf55SThomas Lively  ret <2 x i64> %res
182720fbf55SThomas Lively}
183720fbf55SThomas Lively
184720fbf55SThomas Lively; CHECK-LABEL: v2i64_to_v4f32:
185720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
186720fbf55SThomas Lively; SIMD128: return $0
187720fbf55SThomas Livelydefine <4 x float> @v2i64_to_v4f32(<2 x i64> %v) {
188720fbf55SThomas Lively  %res = bitcast <2 x i64> %v to <4 x float>
189720fbf55SThomas Lively  ret <4 x float> %res
190720fbf55SThomas Lively}
191720fbf55SThomas Lively
192720fbf55SThomas Lively; CHECK-LABEL: v2i64_to_v2f64:
193720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
194720fbf55SThomas Lively; SIMD128: return $0
195720fbf55SThomas Livelydefine <2 x double> @v2i64_to_v2f64(<2 x i64> %v) {
196720fbf55SThomas Lively  %res = bitcast <2 x i64> %v to <2 x double>
197720fbf55SThomas Lively  ret <2 x double> %res
198720fbf55SThomas Lively}
199720fbf55SThomas Lively
200720fbf55SThomas Lively; CHECK-LABEL: v4f32_to_v16i8:
201720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
202720fbf55SThomas Lively; SIMD128: return $0
203720fbf55SThomas Livelydefine <16 x i8> @v4f32_to_v16i8(<4 x float> %v) {
204720fbf55SThomas Lively  %res = bitcast <4 x float> %v to <16 x i8>
205720fbf55SThomas Lively  ret <16 x i8> %res
206720fbf55SThomas Lively}
207720fbf55SThomas Lively
208720fbf55SThomas Lively; CHECK-LABEL: v4f32_to_v8i16:
209720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
210720fbf55SThomas Lively; SIMD128: return $0
211720fbf55SThomas Livelydefine <8 x i16> @v4f32_to_v8i16(<4 x float> %v) {
212720fbf55SThomas Lively  %res = bitcast <4 x float> %v to <8 x i16>
213720fbf55SThomas Lively  ret <8 x i16> %res
214720fbf55SThomas Lively}
215720fbf55SThomas Lively
216720fbf55SThomas Lively; CHECK-LABEL: v4f32_to_v4i32:
217720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
218720fbf55SThomas Lively; SIMD128: return $0
219720fbf55SThomas Livelydefine <4 x i32> @v4f32_to_v4i32(<4 x float> %v) {
220720fbf55SThomas Lively  %res = bitcast <4 x float> %v to <4 x i32>
221720fbf55SThomas Lively  ret <4 x i32> %res
222720fbf55SThomas Lively}
223720fbf55SThomas Lively
224720fbf55SThomas Lively; CHECK-LABEL: v4f32_to_v2i64:
225720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
226720fbf55SThomas Lively; SIMD128: return $0
227720fbf55SThomas Livelydefine <2 x i64> @v4f32_to_v2i64(<4 x float> %v) {
228720fbf55SThomas Lively  %res = bitcast <4 x float> %v to <2 x i64>
229720fbf55SThomas Lively  ret <2 x i64> %res
230720fbf55SThomas Lively}
231720fbf55SThomas Lively
232720fbf55SThomas Lively; CHECK-LABEL: v4f32_to_v4f32:
233720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
234720fbf55SThomas Lively; SIMD128: return $0
235720fbf55SThomas Livelydefine <4 x float> @v4f32_to_v4f32(<4 x float> %v) {
236720fbf55SThomas Lively  %res = bitcast <4 x float> %v to <4 x float>
237720fbf55SThomas Lively  ret <4 x float> %res
238720fbf55SThomas Lively}
239720fbf55SThomas Lively
240720fbf55SThomas Lively; CHECK-LABEL: v4f32_to_v2f64:
241720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
242720fbf55SThomas Lively; SIMD128: return $0
243720fbf55SThomas Livelydefine <2 x double> @v4f32_to_v2f64(<4 x float> %v) {
244720fbf55SThomas Lively  %res = bitcast <4 x float> %v to <2 x double>
245720fbf55SThomas Lively  ret <2 x double> %res
246720fbf55SThomas Lively}
247720fbf55SThomas Lively
248720fbf55SThomas Lively; CHECK-LABEL: v2f64_to_v16i8:
249720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
250720fbf55SThomas Lively; SIMD128: return $0
251720fbf55SThomas Livelydefine <16 x i8> @v2f64_to_v16i8(<2 x double> %v) {
252720fbf55SThomas Lively  %res = bitcast <2 x double> %v to <16 x i8>
253720fbf55SThomas Lively  ret <16 x i8> %res
254720fbf55SThomas Lively}
255720fbf55SThomas Lively
256720fbf55SThomas Lively; CHECK-LABEL: v2f64_to_v8i16:
257720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
258720fbf55SThomas Lively; SIMD128: return $0
259720fbf55SThomas Livelydefine <8 x i16> @v2f64_to_v8i16(<2 x double> %v) {
260720fbf55SThomas Lively  %res = bitcast <2 x double> %v to <8 x i16>
261720fbf55SThomas Lively  ret <8 x i16> %res
262720fbf55SThomas Lively}
263720fbf55SThomas Lively
264720fbf55SThomas Lively; CHECK-LABEL: v2f64_to_v4i32:
265720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
266720fbf55SThomas Lively; SIMD128: return $0
267720fbf55SThomas Livelydefine <4 x i32> @v2f64_to_v4i32(<2 x double> %v) {
268720fbf55SThomas Lively  %res = bitcast <2 x double> %v to <4 x i32>
269720fbf55SThomas Lively  ret <4 x i32> %res
270720fbf55SThomas Lively}
271720fbf55SThomas Lively
272720fbf55SThomas Lively; CHECK-LABEL: v2f64_to_v2i64:
273720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
274720fbf55SThomas Lively; SIMD128: return $0
275720fbf55SThomas Livelydefine <2 x i64> @v2f64_to_v2i64(<2 x double> %v) {
276720fbf55SThomas Lively  %res = bitcast <2 x double> %v to <2 x i64>
277720fbf55SThomas Lively  ret <2 x i64> %res
278720fbf55SThomas Lively}
279720fbf55SThomas Lively
280720fbf55SThomas Lively; CHECK-LABEL: v2f64_to_v4f32:
281720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
282720fbf55SThomas Lively; SIMD128: return $0
283720fbf55SThomas Livelydefine <4 x float> @v2f64_to_v4f32(<2 x double> %v) {
284720fbf55SThomas Lively  %res = bitcast <2 x double> %v to <4 x float>
285720fbf55SThomas Lively  ret <4 x float> %res
286720fbf55SThomas Lively}
287720fbf55SThomas Lively
288720fbf55SThomas Lively; CHECK-LABEL: v2f64_to_v2f64:
289720fbf55SThomas Lively; NO-SIMD128-NOT: return $0
290720fbf55SThomas Lively; SIMD128: return $0
291720fbf55SThomas Livelydefine <2 x double> @v2f64_to_v2f64(<2 x double> %v) {
292720fbf55SThomas Lively  %res = bitcast <2 x double> %v to <2 x double>
293720fbf55SThomas Lively  ret <2 x double> %res
294720fbf55SThomas Lively}
295