xref: /llvm-project/llvm/test/CodeGen/WebAssembly/simd-extending-convert.ll (revision 18077e9fd688443ca111111541e7e3a71236efd5)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mattr=+simd128 | FileCheck %s
3
4; TODO: These tests should check that floating point conversions select
5; extending instructions where possible
6
7target triple = "wasm32-unknown-unknown"
8
9define <4 x float> @extend_to_float_low_i16x8_u(<8 x i16> %x) {
10; CHECK-LABEL: extend_to_float_low_i16x8_u:
11; CHECK:         .functype extend_to_float_low_i16x8_u (v128) -> (v128)
12; CHECK-NEXT:  # %bb.0:
13; CHECK-NEXT:    local.get 0
14; CHECK-NEXT:    i32x4.extend_low_i16x8_u
15; CHECK-NEXT:    f32x4.convert_i32x4_u
16; CHECK-NEXT:    # fallthrough-return
17  %low = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
18  %extended = uitofp <4 x i16> %low to <4 x float>
19  ret <4 x float> %extended
20}
21
22define <4 x float> @extend_to_float_high_i16x8_u(<8 x i16> %x) {
23; CHECK-LABEL: extend_to_float_high_i16x8_u:
24; CHECK:         .functype extend_to_float_high_i16x8_u (v128) -> (v128)
25; CHECK-NEXT:  # %bb.0:
26; CHECK-NEXT:    local.get 0
27; CHECK-NEXT:    i32x4.extend_high_i16x8_u
28; CHECK-NEXT:    f32x4.convert_i32x4_u
29; CHECK-NEXT:    # fallthrough-return
30  %high = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
31  %extended = uitofp <4 x i16> %high to <4 x float>
32  ret <4 x float> %extended
33}
34
35define <4 x float> @extend_to_float_low_i8x16_u(<8 x i8> %x) {
36; CHECK-LABEL: extend_to_float_low_i8x16_u:
37; CHECK:         .functype extend_to_float_low_i8x16_u (v128) -> (v128)
38; CHECK-NEXT:  # %bb.0:
39; CHECK-NEXT:    local.get 0
40; CHECK-NEXT:    i16x8.extend_low_i8x16_u
41; CHECK-NEXT:    i32x4.extend_low_i16x8_u
42; CHECK-NEXT:    f32x4.convert_i32x4_u
43; CHECK-NEXT:    # fallthrough-return
44  %low = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
45  %extended = uitofp <4 x i8> %low to <4 x float>
46  ret <4 x float> %extended
47}
48
49define <4 x float> @extend_to_float_high_i8x16_u(<8 x i8> %x) {
50; CHECK-LABEL: extend_to_float_high_i8x16_u:
51; CHECK:         .functype extend_to_float_high_i8x16_u (v128) -> (v128)
52; CHECK-NEXT:  # %bb.0:
53; CHECK-NEXT:    local.get 0
54; CHECK-NEXT:    local.get 0
55; CHECK-NEXT:    i8x16.shuffle 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
56; CHECK-NEXT:    i16x8.extend_low_i8x16_u
57; CHECK-NEXT:    i32x4.extend_low_i16x8_u
58; CHECK-NEXT:    f32x4.convert_i32x4_u
59; CHECK-NEXT:    # fallthrough-return
60  %high = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
61  %extended = uitofp <4 x i8> %high to <4 x float>
62  ret <4 x float> %extended
63}
64
65define <4 x float> @extend_to_float_low_i16x8_s(<8 x i16> %x) {
66; CHECK-LABEL: extend_to_float_low_i16x8_s:
67; CHECK:         .functype extend_to_float_low_i16x8_s (v128) -> (v128)
68; CHECK-NEXT:  # %bb.0:
69; CHECK-NEXT:    local.get 0
70; CHECK-NEXT:    i32x4.extend_low_i16x8_s
71; CHECK-NEXT:    f32x4.convert_i32x4_s
72; CHECK-NEXT:    # fallthrough-return
73  %low = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
74  %extended = sitofp <4 x i16> %low to <4 x float>
75  ret <4 x float> %extended
76}
77
78define <4 x float> @extend_to_float_high_i16x8_s(<8 x i16> %x) {
79; CHECK-LABEL: extend_to_float_high_i16x8_s:
80; CHECK:         .functype extend_to_float_high_i16x8_s (v128) -> (v128)
81; CHECK-NEXT:  # %bb.0:
82; CHECK-NEXT:    local.get 0
83; CHECK-NEXT:    i32x4.extend_high_i16x8_s
84; CHECK-NEXT:    f32x4.convert_i32x4_s
85; CHECK-NEXT:    # fallthrough-return
86  %high = shufflevector <8 x i16> %x, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
87  %extended = sitofp <4 x i16> %high to <4 x float>
88  ret <4 x float> %extended
89}
90
91define <4 x float> @extend_to_float_low_i8x16_s(<8 x i8> %x) {
92; CHECK-LABEL: extend_to_float_low_i8x16_s:
93; CHECK:         .functype extend_to_float_low_i8x16_s (v128) -> (v128)
94; CHECK-NEXT:  # %bb.0:
95; CHECK-NEXT:    local.get 0
96; CHECK-NEXT:    i16x8.extend_low_i8x16_s
97; CHECK-NEXT:    i32x4.extend_low_i16x8_s
98; CHECK-NEXT:    f32x4.convert_i32x4_s
99; CHECK-NEXT:    # fallthrough-return
100  %low = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
101  %extended = sitofp <4 x i8> %low to <4 x float>
102  ret <4 x float> %extended
103}
104
105define <4 x float> @extend_to_float_high_i8x16_s(<8 x i8> %x) {
106; CHECK-LABEL: extend_to_float_high_i8x16_s:
107; CHECK:         .functype extend_to_float_high_i8x16_s (v128) -> (v128)
108; CHECK-NEXT:  # %bb.0:
109; CHECK-NEXT:    local.get 0
110; CHECK-NEXT:    local.get 0
111; CHECK-NEXT:    i8x16.shuffle 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
112; CHECK-NEXT:    i16x8.extend_low_i8x16_s
113; CHECK-NEXT:    i32x4.extend_low_i16x8_s
114; CHECK-NEXT:    f32x4.convert_i32x4_s
115; CHECK-NEXT:    # fallthrough-return
116  %high = shufflevector <8 x i8> %x, <8 x i8> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
117  %extended = sitofp <4 x i8> %high to <4 x float>
118  ret <4 x float> %extended
119}
120
121define <2 x double> @extend_to_double_low_i32x4_u(<4 x i32> %x) {
122; CHECK-LABEL: extend_to_double_low_i32x4_u:
123; CHECK:         .functype extend_to_double_low_i32x4_u (v128) -> (v128)
124; CHECK-NEXT:  # %bb.0:
125; CHECK-NEXT:    local.get 0
126; CHECK-NEXT:    f64x2.convert_low_i32x4_u
127; CHECK-NEXT:    # fallthrough-return
128  %low = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 0, i32 1>
129  %extended = uitofp <2 x i32> %low to <2 x double>
130  ret <2 x double> %extended
131}
132
133define <2 x double> @extend_to_double_low_i16x4_u(<4 x i16> %x) {
134; CHECK-LABEL: extend_to_double_low_i16x4_u:
135; CHECK:         .functype extend_to_double_low_i16x4_u (v128) -> (v128)
136; CHECK-NEXT:  # %bb.0:
137; CHECK-NEXT:    local.get 0
138; CHECK-NEXT:    i32x4.extend_low_i16x8_u
139; CHECK-NEXT:    f64x2.convert_low_i32x4_u
140; CHECK-NEXT:    # fallthrough-return
141  %low = shufflevector <4 x i16> %x, <4 x i16> undef, <2 x i32> <i32 0, i32 1>
142  %extended = uitofp <2 x i16> %low to <2 x double>
143  ret <2 x double> %extended
144}
145