llvm.org GIT mirror llvm / 93627d9
[InstSimplify] Add tests to show missed bitcast folding opportunities. InstSimplify doesn't always know how to fold a bitcast of a constant vector. In particular, the logic in InstSimplify doesn't know how to handle the case where the constant vector in input contains some undef elements, and the number of elements is smaller than the number of elements of the bitcast vector type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281332 91177308-0d34-0410-b5e6-96231b3b80d8 Andrea Di Biagio 3 years ago
1 changed file(s) with 144 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
122122 %cast = bitcast <4 x i32> to <2 x double>
123123 ret <2 x double> %cast
124124 }
125
126 define <4 x i32> @bitcast_constexpr_4i32_2i64_u2() {
127 ; CHECK-LABEL: @bitcast_constexpr_4i32_2i64_u2(
128 ; CHECK-NEXT: ret <4 x i32> bitcast (<2 x i64> to <4 x i32>)
129 ;
130 %cast = bitcast <2 x i64> to <4 x i32>
131 ret <4 x i32> %cast
132 }
133
134 define <4 x i32> @bitcast_constexpr_4i32_2i64_1u() {
135 ; CHECK-LABEL: @bitcast_constexpr_4i32_2i64_1u(
136 ; CHECK-NEXT: ret <4 x i32> bitcast (<2 x i64> to <4 x i32>)
137 ;
138 %cast = bitcast <2 x i64> to <4 x i32>
139 ret <4 x i32> %cast
140 }
141
142 define <4 x i32> @bitcast_constexpr_4i32_2i64() {
143 ; CHECK-LABEL: @bitcast_constexpr_4i32_2i64(
144 ; CHECK-NEXT: ret <4 x i32> bitcast (<2 x i64> to <4 x i32>)
145 ;
146 %cast = bitcast <2 x i64> to <4 x i32>
147 ret <4 x i32> %cast
148 }
149
150 define <8 x i16> @bitcast_constexpr_8i16_2i64_u2() {
151 ; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_u2(
152 ; CHECK-NEXT: ret <8 x i16> bitcast (<2 x i64> to <8 x i16>)
153 ;
154 %cast = bitcast <2 x i64> to <8 x i16>
155 ret <8 x i16> %cast
156 }
157
158 define <8 x i16> @bitcast_constexpr_8i16_2i64_1u() {
159 ; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_1u(
160 ; CHECK-NEXT: ret <8 x i16> bitcast (<2 x i64> to <8 x i16>)
161 ;
162 %cast = bitcast <2 x i64> to <8 x i16>
163 ret <8 x i16> %cast
164 }
165
166 define <8 x i16> @bitcast_constexpr_8i16_2i64_u65536() {
167 ; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_u65536(
168 ; CHECK-NEXT: ret <8 x i16> bitcast (<2 x i64> to <8 x i16>)
169 ;
170 %cast = bitcast <2 x i64> to <8 x i16>
171 ret <8 x i16> %cast
172 }
173
174 define <16 x i8> @bitcast_constexpr_16i8_2i64_u2() {
175 ; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_u2(
176 ; CHECK-NEXT: ret <16 x i8> bitcast (<2 x i64> to <16 x i8>)
177 ;
178 %cast = bitcast <2 x i64> to <16 x i8>
179 ret <16 x i8> %cast
180 }
181
182 define <16 x i8> @bitcast_constexpr_16i8_2i64_256u() {
183 ; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_256u(
184 ; CHECK-NEXT: ret <16 x i8> bitcast (<2 x i64> to <16 x i8>)
185 ;
186 %cast = bitcast <2 x i64> to <16 x i8>
187 ret <16 x i8> %cast
188 }
189
190 define <16 x i8> @bitcast_constexpr_16i8_2i64_u256() {
191 ; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_u256(
192 ; CHECK-NEXT: ret <16 x i8> bitcast (<2 x i64> to <16 x i8>)
193 ;
194 %cast = bitcast <2 x i64> to <16 x i8>
195 ret <16 x i8> %cast
196 }
197
198 define <8 x i16> @bitcast_constexpr_8i16_4i32_uu22() {
199 ; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_uu22(
200 ; CHECK-NEXT: ret <8 x i16> bitcast (<4 x i32> to <8 x i16>)
201 ;
202 %cast = bitcast <4 x i32> to <8 x i16>
203 ret <8 x i16> %cast
204 }
205
206 define <8 x i16> @bitcast_constexpr_8i16_4i32_10uu() {
207 ; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_10uu(
208 ; CHECK-NEXT: ret <8 x i16> bitcast (<4 x i32> to <8 x i16>)
209 ;
210 %cast = bitcast <4 x i32> to <8 x i16>
211 ret <8 x i16> %cast
212 }
213
214 define <8 x i16> @bitcast_constexpr_8i16_4i32_u257u256() {
215 ; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_u257u256(
216 ; CHECK-NEXT: ret <8 x i16> bitcast (<4 x i32> to <8 x i16>)
217 ;
218 %cast = bitcast <4 x i32> to <8 x i16>
219 ret <8 x i16> %cast
220 }
221
222 define <16 x i8> @bitcast_constexpr_16i8_4i32_u2u2() {
223 ; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_u2u2(
224 ; CHECK-NEXT: ret <16 x i8> bitcast (<4 x i32> to <16 x i8>)
225 ;
226 %cast = bitcast <4 x i32> to <16 x i8>
227 ret <16 x i8> %cast
228 }
229
230 define <16 x i8> @bitcast_constexpr_16i8_4i32_1u1u() {
231 ; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_1u1u(
232 ; CHECK-NEXT: ret <16 x i8> bitcast (<4 x i32> to <16 x i8>)
233 ;
234 %cast = bitcast <4 x i32> to <16 x i8>
235 ret <16 x i8> %cast
236 }
237
238 define <16 x i8> @bitcast_constexpr_16i8_4i32_u256uu() {
239 ; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_u256uu(
240 ; CHECK-NEXT: ret <16 x i8> bitcast (<4 x i32> to <16 x i8>)
241 ;
242 %cast = bitcast <4 x i32> to <16 x i8>
243 ret <16 x i8> %cast
244 }
245
246 define <16 x i8> @bitcast_constexpr_16i8_8i16_u2u2u2u2() {
247 ; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_u2u2u2u2(
248 ; CHECK-NEXT: ret <16 x i8> bitcast (<8 x i16> to <16 x i8>)
249 ;
250 %cast = bitcast <8 x i16> to <16 x i8>
251 ret <16 x i8> %cast
252 }
253
254 define <16 x i8> @bitcast_constexpr_16i8_8i16_1u1u1u1u() {
255 ; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_1u1u1u1u(
256 ; CHECK-NEXT: ret <16 x i8> bitcast (<8 x i16> to <16 x i8>)
257 ;
258 %cast = bitcast <8 x i16> to <16 x i8>
259 ret <16 x i8> %cast
260 }
261
262 define <16 x i8> @bitcast_constexpr_16i8_8i16_u256uuu256uu() {
263 ; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_u256uuu256uu(
264 ; CHECK-NEXT: ret <16 x i8> bitcast (<8 x i16> to <16 x i8>)
265 ;
266 %cast = bitcast <8 x i16> to <16 x i8>
267 ret <16 x i8> %cast
268 }