1 ; 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
2 ; 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
4 ; Test that bitcasts between vector types are lowered to zero instructions
6 target triple = "wasm32-unknown-unknown"
8 ; CHECK-LABEL: v16i8_to_v16i8:
9 ; NO-SIMD128-NOT: return $0
11 define <16 x i8> @v16i8_to_v16i8(<16 x i8> %v) {
12 %res = bitcast <16 x i8> %v to <16 x i8>
16 ; CHECK-LABEL: v16i8_to_v8i16:
17 ; NO-SIMD128-NOT: return $0
19 define <8 x i16> @v16i8_to_v8i16(<16 x i8> %v) {
20 %res = bitcast <16 x i8> %v to <8 x i16>
24 ; CHECK-LABEL: v16i8_to_v4i32:
25 ; NO-SIMD128-NOT: return $0
27 define <4 x i32> @v16i8_to_v4i32(<16 x i8> %v) {
28 %res = bitcast <16 x i8> %v to <4 x i32>
32 ; CHECK-LABEL: v16i8_to_v2i64:
33 ; NO-SIMD128-NOT: return $0
35 define <2 x i64> @v16i8_to_v2i64(<16 x i8> %v) {
36 %res = bitcast <16 x i8> %v to <2 x i64>
40 ; CHECK-LABEL: v16i8_to_v4f32:
41 ; NO-SIMD128-NOT: return $0
43 define <4 x float> @v16i8_to_v4f32(<16 x i8> %v) {
44 %res = bitcast <16 x i8> %v to <4 x float>
48 ; CHECK-LABEL: v16i8_to_v2f64:
49 ; NO-SIMD128-NOT: return $0
51 define <2 x double> @v16i8_to_v2f64(<16 x i8> %v) {
52 %res = bitcast <16 x i8> %v to <2 x double>
56 ; CHECK-LABEL: v8i16_to_v16i8:
57 ; NO-SIMD128-NOT: return $0
59 define <16 x i8> @v8i16_to_v16i8(<8 x i16> %v) {
60 %res = bitcast <8 x i16> %v to <16 x i8>
64 ; CHECK-LABEL: v8i16_to_v8i16:
65 ; NO-SIMD128-NOT: return $0
67 define <8 x i16> @v8i16_to_v8i16(<8 x i16> %v) {
68 %res = bitcast <8 x i16> %v to <8 x i16>
72 ; CHECK-LABEL: v8i16_to_v4i32:
73 ; NO-SIMD128-NOT: return $0
75 define <4 x i32> @v8i16_to_v4i32(<8 x i16> %v) {
76 %res = bitcast <8 x i16> %v to <4 x i32>
80 ; CHECK-LABEL: v8i16_to_v2i64:
81 ; NO-SIMD128-NOT: return $0
83 define <2 x i64> @v8i16_to_v2i64(<8 x i16> %v) {
84 %res = bitcast <8 x i16> %v to <2 x i64>
88 ; CHECK-LABEL: v8i16_to_v4f32:
89 ; NO-SIMD128-NOT: return $0
91 define <4 x float> @v8i16_to_v4f32(<8 x i16> %v) {
92 %res = bitcast <8 x i16> %v to <4 x float>
96 ; CHECK-LABEL: v8i16_to_v2f64:
97 ; NO-SIMD128-NOT: return $0
99 define <2 x double> @v8i16_to_v2f64(<8 x i16> %v) {
100 %res = bitcast <8 x i16> %v to <2 x double>
101 ret <2 x double> %res
104 ; CHECK-LABEL: v4i32_to_v16i8:
105 ; NO-SIMD128-NOT: return $0
107 define <16 x i8> @v4i32_to_v16i8(<4 x i32> %v) {
108 %res = bitcast <4 x i32> %v to <16 x i8>
112 ; CHECK-LABEL: v4i32_to_v8i16:
113 ; NO-SIMD128-NOT: return $0
115 define <8 x i16> @v4i32_to_v8i16(<4 x i32> %v) {
116 %res = bitcast <4 x i32> %v to <8 x i16>
120 ; CHECK-LABEL: v4i32_to_v4i32:
121 ; NO-SIMD128-NOT: return $0
123 define <4 x i32> @v4i32_to_v4i32(<4 x i32> %v) {
124 %res = bitcast <4 x i32> %v to <4 x i32>
128 ; CHECK-LABEL: v4i32_to_v2i64:
129 ; NO-SIMD128-NOT: return $0
131 define <2 x i64> @v4i32_to_v2i64(<4 x i32> %v) {
132 %res = bitcast <4 x i32> %v to <2 x i64>
136 ; CHECK-LABEL: v4i32_to_v4f32:
137 ; NO-SIMD128-NOT: return $0
139 define <4 x float> @v4i32_to_v4f32(<4 x i32> %v) {
140 %res = bitcast <4 x i32> %v to <4 x float>
144 ; CHECK-LABEL: v4i32_to_v2f64:
145 ; NO-SIMD128-NOT: return $0
147 define <2 x double> @v4i32_to_v2f64(<4 x i32> %v) {
148 %res = bitcast <4 x i32> %v to <2 x double>
149 ret <2 x double> %res
152 ; CHECK-LABEL: v2i64_to_v16i8:
153 ; NO-SIMD128-NOT: return $0
155 define <16 x i8> @v2i64_to_v16i8(<2 x i64> %v) {
156 %res = bitcast <2 x i64> %v to <16 x i8>
160 ; CHECK-LABEL: v2i64_to_v8i16:
161 ; NO-SIMD128-NOT: return $0
163 define <8 x i16> @v2i64_to_v8i16(<2 x i64> %v) {
164 %res = bitcast <2 x i64> %v to <8 x i16>
168 ; CHECK-LABEL: v2i64_to_v4i32:
169 ; NO-SIMD128-NOT: return $0
171 define <4 x i32> @v2i64_to_v4i32(<2 x i64> %v) {
172 %res = bitcast <2 x i64> %v to <4 x i32>
176 ; CHECK-LABEL: v2i64_to_v2i64:
177 ; NO-SIMD128-NOT: return $0
179 define <2 x i64> @v2i64_to_v2i64(<2 x i64> %v) {
180 %res = bitcast <2 x i64> %v to <2 x i64>
184 ; CHECK-LABEL: v2i64_to_v4f32:
185 ; NO-SIMD128-NOT: return $0
187 define <4 x float> @v2i64_to_v4f32(<2 x i64> %v) {
188 %res = bitcast <2 x i64> %v to <4 x float>
192 ; CHECK-LABEL: v2i64_to_v2f64:
193 ; NO-SIMD128-NOT: return $0
195 define <2 x double> @v2i64_to_v2f64(<2 x i64> %v) {
196 %res = bitcast <2 x i64> %v to <2 x double>
197 ret <2 x double> %res
200 ; CHECK-LABEL: v4f32_to_v16i8:
201 ; NO-SIMD128-NOT: return $0
203 define <16 x i8> @v4f32_to_v16i8(<4 x float> %v) {
204 %res = bitcast <4 x float> %v to <16 x i8>
208 ; CHECK-LABEL: v4f32_to_v8i16:
209 ; NO-SIMD128-NOT: return $0
211 define <8 x i16> @v4f32_to_v8i16(<4 x float> %v) {
212 %res = bitcast <4 x float> %v to <8 x i16>
216 ; CHECK-LABEL: v4f32_to_v4i32:
217 ; NO-SIMD128-NOT: return $0
219 define <4 x i32> @v4f32_to_v4i32(<4 x float> %v) {
220 %res = bitcast <4 x float> %v to <4 x i32>
224 ; CHECK-LABEL: v4f32_to_v2i64:
225 ; NO-SIMD128-NOT: return $0
227 define <2 x i64> @v4f32_to_v2i64(<4 x float> %v) {
228 %res = bitcast <4 x float> %v to <2 x i64>
232 ; CHECK-LABEL: v4f32_to_v4f32:
233 ; NO-SIMD128-NOT: return $0
235 define <4 x float> @v4f32_to_v4f32(<4 x float> %v) {
236 %res = bitcast <4 x float> %v to <4 x float>
240 ; CHECK-LABEL: v4f32_to_v2f64:
241 ; NO-SIMD128-NOT: return $0
243 define <2 x double> @v4f32_to_v2f64(<4 x float> %v) {
244 %res = bitcast <4 x float> %v to <2 x double>
245 ret <2 x double> %res
248 ; CHECK-LABEL: v2f64_to_v16i8:
249 ; NO-SIMD128-NOT: return $0
251 define <16 x i8> @v2f64_to_v16i8(<2 x double> %v) {
252 %res = bitcast <2 x double> %v to <16 x i8>
256 ; CHECK-LABEL: v2f64_to_v8i16:
257 ; NO-SIMD128-NOT: return $0
259 define <8 x i16> @v2f64_to_v8i16(<2 x double> %v) {
260 %res = bitcast <2 x double> %v to <8 x i16>
264 ; CHECK-LABEL: v2f64_to_v4i32:
265 ; NO-SIMD128-NOT: return $0
267 define <4 x i32> @v2f64_to_v4i32(<2 x double> %v) {
268 %res = bitcast <2 x double> %v to <4 x i32>
272 ; CHECK-LABEL: v2f64_to_v2i64:
273 ; NO-SIMD128-NOT: return $0
275 define <2 x i64> @v2f64_to_v2i64(<2 x double> %v) {
276 %res = bitcast <2 x double> %v to <2 x i64>
280 ; CHECK-LABEL: v2f64_to_v4f32:
281 ; NO-SIMD128-NOT: return $0
283 define <4 x float> @v2f64_to_v4f32(<2 x double> %v) {
284 %res = bitcast <2 x double> %v to <4 x float>
288 ; CHECK-LABEL: v2f64_to_v2f64:
289 ; NO-SIMD128-NOT: return $0
291 define <2 x double> @v2f64_to_v2f64(<2 x double> %v) {
292 %res = bitcast <2 x double> %v to <2 x double>
293 ret <2 x double> %res