1 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+unimplemented-simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
2 ; 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-VM
3 ; 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
5 ; Test that bitcasts between vector types are lowered to zero instructions
7 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8 target triple = "wasm32-unknown-unknown"
10 ; CHECK-LABEL: v16i8_to_v16i8:
11 ; NO-SIMD128-NOT: return $0
13 define <16 x i8> @v16i8_to_v16i8(<16 x i8> %v) {
14 %res = bitcast <16 x i8> %v to <16 x i8>
18 ; CHECK-LABEL: v16i8_to_v8i16:
19 ; NO-SIMD128-NOT: return $0
21 define <8 x i16> @v16i8_to_v8i16(<16 x i8> %v) {
22 %res = bitcast <16 x i8> %v to <8 x i16>
26 ; CHECK-LABEL: v16i8_to_v4i32:
27 ; NO-SIMD128-NOT: return $0
29 define <4 x i32> @v16i8_to_v4i32(<16 x i8> %v) {
30 %res = bitcast <16 x i8> %v to <4 x i32>
34 ; CHECK-LABEL: v16i8_to_v2i64:
35 ; NO-SIMD128-NOT: return $0
36 ; SIMD128-VM: v128.store
37 ; SIMD128-VM-NEXT: return{{$}}
39 define <2 x i64> @v16i8_to_v2i64(<16 x i8> %v) {
40 %res = bitcast <16 x i8> %v to <2 x i64>
44 ; CHECK-LABEL: v16i8_to_v4f32:
45 ; NO-SIMD128-NOT: return $0
47 define <4 x float> @v16i8_to_v4f32(<16 x i8> %v) {
48 %res = bitcast <16 x i8> %v to <4 x float>
52 ; CHECK-LABEL: v16i8_to_v2f64:
53 ; NO-SIMD128-NOT: return $0
54 ; SIMD128-VM: v128.store
55 ; SIMD128-VM-NEXT: return{{$}}
57 define <2 x double> @v16i8_to_v2f64(<16 x i8> %v) {
58 %res = bitcast <16 x i8> %v to <2 x double>
62 ; CHECK-LABEL: v8i16_to_v16i8:
63 ; NO-SIMD128-NOT: return $0
65 define <16 x i8> @v8i16_to_v16i8(<8 x i16> %v) {
66 %res = bitcast <8 x i16> %v to <16 x i8>
70 ; CHECK-LABEL: v8i16_to_v8i16:
71 ; NO-SIMD128-NOT: return $0
73 define <8 x i16> @v8i16_to_v8i16(<8 x i16> %v) {
74 %res = bitcast <8 x i16> %v to <8 x i16>
78 ; CHECK-LABEL: v8i16_to_v4i32:
79 ; NO-SIMD128-NOT: return $0
81 define <4 x i32> @v8i16_to_v4i32(<8 x i16> %v) {
82 %res = bitcast <8 x i16> %v to <4 x i32>
86 ; CHECK-LABEL: v8i16_to_v2i64:
87 ; NO-SIMD128-NOT: return $0
88 ; SIMD128-VM: v128.store
89 ; SIMD128-VM-NEXT: return{{$}}
91 define <2 x i64> @v8i16_to_v2i64(<8 x i16> %v) {
92 %res = bitcast <8 x i16> %v to <2 x i64>
96 ; CHECK-LABEL: v8i16_to_v4f32:
97 ; NO-SIMD128-NOT: return $0
99 define <4 x float> @v8i16_to_v4f32(<8 x i16> %v) {
100 %res = bitcast <8 x i16> %v to <4 x float>
104 ; CHECK-LABEL: v8i16_to_v2f64:
105 ; NO-SIMD128-NOT: return $0
106 ; SIMD128-VM: v128.store
107 ; SIMD128-VM-NEXT: return{{$}}
109 define <2 x double> @v8i16_to_v2f64(<8 x i16> %v) {
110 %res = bitcast <8 x i16> %v to <2 x double>
111 ret <2 x double> %res
114 ; CHECK-LABEL: v4i32_to_v16i8:
115 ; NO-SIMD128-NOT: return $0
117 define <16 x i8> @v4i32_to_v16i8(<4 x i32> %v) {
118 %res = bitcast <4 x i32> %v to <16 x i8>
122 ; CHECK-LABEL: v4i32_to_v8i16:
123 ; NO-SIMD128-NOT: return $0
125 define <8 x i16> @v4i32_to_v8i16(<4 x i32> %v) {
126 %res = bitcast <4 x i32> %v to <8 x i16>
130 ; CHECK-LABEL: v4i32_to_v4i32:
131 ; NO-SIMD128-NOT: return $0
133 define <4 x i32> @v4i32_to_v4i32(<4 x i32> %v) {
134 %res = bitcast <4 x i32> %v to <4 x i32>
138 ; CHECK-LABEL: v4i32_to_v2i64:
139 ; NO-SIMD128-NOT: return $0
140 ; SIMD128-VM: v128.store
141 ; SIMD128-VM-NEXT: return{{$}}
143 define <2 x i64> @v4i32_to_v2i64(<4 x i32> %v) {
144 %res = bitcast <4 x i32> %v to <2 x i64>
148 ; CHECK-LABEL: v4i32_to_v4f32:
149 ; NO-SIMD128-NOT: return $0
151 define <4 x float> @v4i32_to_v4f32(<4 x i32> %v) {
152 %res = bitcast <4 x i32> %v to <4 x float>
156 ; CHECK-LABEL: v4i32_to_v2f64:
157 ; NO-SIMD128-NOT: return $0
158 ; SIMD128-VM: v128.store
159 ; SIMD128-VM-NEXT: return{{$}}
161 define <2 x double> @v4i32_to_v2f64(<4 x i32> %v) {
162 %res = bitcast <4 x i32> %v to <2 x double>
163 ret <2 x double> %res
166 ; CHECK-LABEL: v2i64_to_v16i8:
167 ; NO-SIMD128-NOT: return $0
168 ; SIMD128-VM-NOT: return $0
170 define <16 x i8> @v2i64_to_v16i8(<2 x i64> %v) {
171 %res = bitcast <2 x i64> %v to <16 x i8>
175 ; CHECK-LABEL: v2i64_to_v8i16:
176 ; NO-SIMD128-NOT: return $0
177 ; SIMD128-VM-NOT: return $0
179 define <8 x i16> @v2i64_to_v8i16(<2 x i64> %v) {
180 %res = bitcast <2 x i64> %v to <8 x i16>
184 ; CHECK-LABEL: v2i64_to_v4i32:
185 ; NO-SIMD128-NOT: return $0
186 ; SIMD128-VM-NOT: return $0
188 define <4 x i32> @v2i64_to_v4i32(<2 x i64> %v) {
189 %res = bitcast <2 x i64> %v to <4 x i32>
193 ; CHECK-LABEL: v2i64_to_v2i64:
194 ; NO-SIMD128-NOT: return $0
195 ; SIMD128-VM-NOT: return $0
197 define <2 x i64> @v2i64_to_v2i64(<2 x i64> %v) {
198 %res = bitcast <2 x i64> %v to <2 x i64>
202 ; CHECK-LABEL: v2i64_to_v4f32:
203 ; NO-SIMD128-NOT: return $0
204 ; SIMD128-VM-NOT: return $0
206 define <4 x float> @v2i64_to_v4f32(<2 x i64> %v) {
207 %res = bitcast <2 x i64> %v to <4 x float>
211 ; CHECK-LABEL: v2i64_to_v2f64:
212 ; NO-SIMD128-NOT: return $0
213 ; SIMD128-VM-NOT: return $0
215 define <2 x double> @v2i64_to_v2f64(<2 x i64> %v) {
216 %res = bitcast <2 x i64> %v to <2 x double>
217 ret <2 x double> %res
220 ; CHECK-LABEL: v4f32_to_v16i8:
221 ; NO-SIMD128-NOT: return $0
223 define <16 x i8> @v4f32_to_v16i8(<4 x float> %v) {
224 %res = bitcast <4 x float> %v to <16 x i8>
228 ; CHECK-LABEL: v4f32_to_v8i16:
229 ; NO-SIMD128-NOT: return $0
231 define <8 x i16> @v4f32_to_v8i16(<4 x float> %v) {
232 %res = bitcast <4 x float> %v to <8 x i16>
236 ; CHECK-LABEL: v4f32_to_v4i32:
237 ; NO-SIMD128-NOT: return $0
239 define <4 x i32> @v4f32_to_v4i32(<4 x float> %v) {
240 %res = bitcast <4 x float> %v to <4 x i32>
244 ; CHECK-LABEL: v4f32_to_v2i64:
245 ; NO-SIMD128-NOT: return $0
246 ; SIMD128-VM: v128.store
247 ; SIMD128-VM-NEXT: return{{$}}
249 define <2 x i64> @v4f32_to_v2i64(<4 x float> %v) {
250 %res = bitcast <4 x float> %v to <2 x i64>
254 ; CHECK-LABEL: v4f32_to_v4f32:
255 ; NO-SIMD128-NOT: return $0
257 define <4 x float> @v4f32_to_v4f32(<4 x float> %v) {
258 %res = bitcast <4 x float> %v to <4 x float>
262 ; CHECK-LABEL: v4f32_to_v2f64:
263 ; NO-SIMD128-NOT: return $0
264 ; SIMD128-VM: v128.store
265 ; SIMD128-VM-NEXT: return{{$}}
267 define <2 x double> @v4f32_to_v2f64(<4 x float> %v) {
268 %res = bitcast <4 x float> %v to <2 x double>
269 ret <2 x double> %res
272 ; CHECK-LABEL: v2f64_to_v16i8:
273 ; NO-SIMD128-NOT: return $0
274 ; SIMD128-VM-NOT: return $0
276 define <16 x i8> @v2f64_to_v16i8(<2 x double> %v) {
277 %res = bitcast <2 x double> %v to <16 x i8>
281 ; CHECK-LABEL: v2f64_to_v8i16:
282 ; NO-SIMD128-NOT: return $0
283 ; SIMD128-VM-NOT: return $0
285 define <8 x i16> @v2f64_to_v8i16(<2 x double> %v) {
286 %res = bitcast <2 x double> %v to <8 x i16>
290 ; CHECK-LABEL: v2f64_to_v4i32:
291 ; NO-SIMD128-NOT: return $0
292 ; SIMD128-VM-NOT: return $0
294 define <4 x i32> @v2f64_to_v4i32(<2 x double> %v) {
295 %res = bitcast <2 x double> %v to <4 x i32>
299 ; CHECK-LABEL: v2f64_to_v2i64:
300 ; NO-SIMD128-NOT: return $0
301 ; SIMD128-VM-NOT: return $0
303 define <2 x i64> @v2f64_to_v2i64(<2 x double> %v) {
304 %res = bitcast <2 x double> %v to <2 x i64>
308 ; CHECK-LABEL: v2f64_to_v4f32:
309 ; NO-SIMD128-NOT: return $0
310 ; SIMD128-VM-NOT: return $0
312 define <4 x float> @v2f64_to_v4f32(<2 x double> %v) {
313 %res = bitcast <2 x double> %v to <4 x float>
317 ; CHECK-LABEL: v2f64_to_v2f64:
318 ; NO-SIMD128-NOT: return $0
319 ; SIMD128-VM-NOT: return $0
321 define <2 x double> @v2f64_to_v2f64(<2 x double> %v) {
322 %res = bitcast <2 x double> %v to <2 x double>
323 ret <2 x double> %res