1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; CHECK-DAG: OpName [[TRUNC32_16:%.*]] "i32toi16"
4 ; CHECK-DAG: OpName [[TRUNC32_8:%.*]] "i32toi8"
5 ; CHECK-DAG: OpName [[TRUNC16_8:%.*]] "i16toi8"
6 ; CHECK-DAG: OpName [[SEXT8_32:%.*]] "s8tos32"
7 ; CHECK-DAG: OpName [[SEXT8_16:%.*]] "s8tos16"
8 ; CHECK-DAG: OpName [[SEXT16_32:%.*]] "s16tos32"
9 ; CHECK-DAG: OpName [[ZEXT8_32:%.*]] "u8tou32"
10 ; CHECK-DAG: OpName [[ZEXT8_16:%.*]] "u8tou16"
11 ; CHECK-DAG: OpName [[ZEXT16_32:%.*]] "u16tou32"
13 ; CHECK-DAG: OpName [[TRUNC32_16v4:%.*]] "i32toi16v4"
14 ; CHECK-DAG: OpName [[TRUNC32_8v4:%.*]] "i32toi8v4"
15 ; CHECK-DAG: OpName [[TRUNC16_8v4:%.*]] "i16toi8v4"
16 ; CHECK-DAG: OpName [[SEXT8_32v4:%.*]] "s8tos32v4"
17 ; CHECK-DAG: OpName [[SEXT8_16v4:%.*]] "s8tos16v4"
18 ; CHECK-DAG: OpName [[SEXT16_32v4:%.*]] "s16tos32v4"
19 ; CHECK-DAG: OpName [[ZEXT8_32v4:%.*]] "u8tou32v4"
20 ; CHECK-DAG: OpName [[ZEXT8_16v4:%.*]] "u8tou16v4"
21 ; CHECK-DAG: OpName [[ZEXT16_32v4:%.*]] "u16tou32v4"
23 ; CHECK-DAG: [[U32:%.*]] = OpTypeInt 32 0
24 ; CHECK-DAG: [[U16:%.*]] = OpTypeInt 16 0
25 ; CHECK-DAG: [[U8:%.*]] = OpTypeInt 8 0
26 ; CHECK-DAG: [[U32v4:%.*]] = OpTypeVector [[U32]] 4
27 ; CHECK-DAG: [[U16v4:%.*]] = OpTypeVector [[U16]] 4
28 ; CHECK-DAG: [[U8v4:%.*]] = OpTypeVector [[U8]] 4
31 ; CHECK: [[TRUNC32_16]] = OpFunction [[U16]]
32 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U32]]
34 ; CHECK: [[R:%.*]] = OpUConvert [[U16]] [[A]]
35 ; CHECK: OpReturnValue [[R]]
36 ; CHECK-NEXT: OpFunctionEnd
37 define i16 @i32toi16(i32 %a) {
38 %r = trunc i32 %a to i16
42 ; CHECK: [[TRUNC32_8]] = OpFunction [[U8]]
43 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U32]]
45 ; CHECK: [[R:%.*]] = OpUConvert [[U8]] [[A]]
46 ; CHECK: OpReturnValue [[R]]
47 ; CHECK-NEXT: OpFunctionEnd
48 define i8 @i32toi8(i32 %a) {
49 %r = trunc i32 %a to i8
53 ; CHECK: [[TRUNC16_8]] = OpFunction [[U8]]
54 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U16]]
56 ; CHECK: [[R:%.*]] = OpUConvert [[U8]] [[A]]
57 ; CHECK: OpReturnValue [[R]]
58 ; CHECK-NEXT: OpFunctionEnd
59 define i8 @i16toi8(i16 %a) {
60 %r = trunc i16 %a to i8
65 ; CHECK: [[SEXT8_32]] = OpFunction [[U32]]
66 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8]]
68 ; CHECK: [[R:%.*]] = OpSConvert [[U32]] [[A]]
69 ; CHECK: OpReturnValue [[R]]
70 ; CHECK-NEXT: OpFunctionEnd
71 define i32 @s8tos32(i8 %a) {
72 %r = sext i8 %a to i32
76 ; CHECK: [[SEXT8_16]] = OpFunction [[U16]]
77 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8]]
79 ; CHECK: [[R:%.*]] = OpSConvert [[U16]] [[A]]
80 ; CHECK: OpReturnValue [[R]]
81 ; CHECK-NEXT: OpFunctionEnd
82 define i16 @s8tos16(i8 %a) {
83 %r = sext i8 %a to i16
87 ; CHECK: [[SEXT16_32]] = OpFunction [[U32]]
88 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U16]]
90 ; CHECK: [[R:%.*]] = OpSConvert [[U32]] [[A]]
91 ; CHECK: OpReturnValue [[R]]
92 ; CHECK-NEXT: OpFunctionEnd
93 define i32 @s16tos32(i16 %a) {
94 %r = sext i16 %a to i32
98 ; CHECK: [[ZEXT8_32]] = OpFunction [[U32]]
99 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8]]
101 ; CHECK: [[R:%.*]] = OpUConvert [[U32]] [[A]]
102 ; CHECK: OpReturnValue [[R]]
103 ; CHECK-NEXT: OpFunctionEnd
104 define i32 @u8tou32(i8 %a) {
105 %r = zext i8 %a to i32
109 ; CHECK: [[ZEXT8_16]] = OpFunction [[U16]]
110 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8]]
112 ; CHECK: [[R:%.*]] = OpUConvert [[U16]] [[A]]
113 ; CHECK: OpReturnValue [[R]]
114 ; CHECK-NEXT: OpFunctionEnd
115 define i16 @u8tou16(i8 %a) {
116 %r = zext i8 %a to i16
120 ; CHECK: [[ZEXT16_32]] = OpFunction [[U32]]
121 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U16]]
123 ; CHECK: [[R:%.*]] = OpUConvert [[U32]] [[A]]
124 ; CHECK: OpReturnValue [[R]]
125 ; CHECK-NEXT: OpFunctionEnd
126 define i32 @u16tou32(i16 %a) {
127 %r = zext i16 %a to i32
131 ; CHECK: [[TRUNC32_16v4]] = OpFunction [[U16v4]]
132 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U32v4]]
134 ; CHECK: [[R:%.*]] = OpUConvert [[U16v4]] [[A]]
135 ; CHECK: OpReturnValue [[R]]
136 ; CHECK-NEXT: OpFunctionEnd
137 define <4 x i16> @i32toi16v4(<4 x i32> %a) {
138 %r = trunc <4 x i32> %a to <4 x i16>
142 ; CHECK: [[TRUNC32_8v4]] = OpFunction [[U8v4]]
143 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U32v4]]
145 ; CHECK: [[R:%.*]] = OpUConvert [[U8v4]] [[A]]
146 ; CHECK: OpReturnValue [[R]]
147 ; CHECK-NEXT: OpFunctionEnd
148 define <4 x i8> @i32toi8v4(<4 x i32> %a) {
149 %r = trunc <4 x i32> %a to <4 x i8>
153 ; CHECK: [[TRUNC16_8v4]] = OpFunction [[U8v4]]
154 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U16v4]]
156 ; CHECK: [[R:%.*]] = OpUConvert [[U8v4]] [[A]]
157 ; CHECK: OpReturnValue [[R]]
158 ; CHECK-NEXT: OpFunctionEnd
159 define <4 x i8> @i16toi8v4(<4 x i16> %a) {
160 %r = trunc <4 x i16> %a to <4 x i8>
165 ; CHECK: [[SEXT8_32v4]] = OpFunction [[U32v4]]
166 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8v4]]
168 ; CHECK: [[R:%.*]] = OpSConvert [[U32v4]] [[A]]
169 ; CHECK: OpReturnValue [[R]]
170 ; CHECK-NEXT: OpFunctionEnd
171 define <4 x i32> @s8tos32v4(<4 x i8> %a) {
172 %r = sext <4 x i8> %a to <4 x i32>
176 ; CHECK: [[SEXT8_16v4]] = OpFunction [[U16v4]]
177 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8v4]]
179 ; CHECK: [[R:%.*]] = OpSConvert [[U16v4]] [[A]]
180 ; CHECK: OpReturnValue [[R]]
181 ; CHECK-NEXT: OpFunctionEnd
182 define <4 x i16> @s8tos16v4(<4 x i8> %a) {
183 %r = sext <4 x i8> %a to <4 x i16>
187 ; CHECK: [[SEXT16_32v4]] = OpFunction [[U32v4]]
188 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U16v4]]
190 ; CHECK: [[R:%.*]] = OpSConvert [[U32v4]] [[A]]
191 ; CHECK: OpReturnValue [[R]]
192 ; CHECK-NEXT: OpFunctionEnd
193 define <4 x i32> @s16tos32v4(<4 x i16> %a) {
194 %r = sext <4 x i16> %a to <4 x i32>
198 ; CHECK: [[ZEXT8_32v4]] = OpFunction [[U32v4]]
199 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8v4]]
201 ; CHECK: [[R:%.*]] = OpUConvert [[U32v4]] [[A]]
202 ; CHECK: OpReturnValue [[R]]
203 ; CHECK-NEXT: OpFunctionEnd
204 define <4 x i32> @u8tou32v4(<4 x i8> %a) {
205 %r = zext <4 x i8> %a to <4 x i32>
209 ; CHECK: [[ZEXT8_16v4]] = OpFunction [[U16v4]]
210 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U8v4]]
212 ; CHECK: [[R:%.*]] = OpUConvert [[U16v4]] [[A]]
213 ; CHECK: OpReturnValue [[R]]
214 ; CHECK-NEXT: OpFunctionEnd
215 define <4 x i16> @u8tou16v4(<4 x i8> %a) {
216 %r = zext <4 x i8> %a to <4 x i16>
220 ; CHECK: [[ZEXT16_32v4]] = OpFunction [[U32v4]]
221 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[U16v4]]
223 ; CHECK: [[R:%.*]] = OpUConvert [[U32v4]] [[A]]
224 ; CHECK: OpReturnValue [[R]]
225 ; CHECK-NEXT: OpFunctionEnd
226 define <4 x i32> @u16tou32v4(<4 x i16> %a) {
227 %r = zext <4 x i16> %a to <4 x i32>