1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instsimplify -S | FileCheck %s
3target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-f64:32:64-v64:64:64-v128:128:128"
4
5define <2 x i64> @test1() {
6; CHECK-LABEL: @test1(
7; CHECK-NEXT:    ret <2 x i64> <i64 4294967296, i64 12884901890>
8;
9  %tmp3 = bitcast <4 x i32> < i32 0, i32 1, i32 2, i32 3 > to <2 x i64>
10  ret <2 x i64> %tmp3
11}
12
13define <4 x i32> @test2() {
14; CHECK-LABEL: @test2(
15; CHECK-NEXT:    ret <4 x i32> <i32 0, i32 0, i32 1, i32 0>
16;
17  %tmp3 = bitcast <2 x i64> < i64 0, i64 1 > to <4 x i32>
18  ret <4 x i32> %tmp3
19}
20
21define <2 x double> @test3() {
22; CHECK-LABEL: @test3(
23; CHECK-NEXT:    ret <2 x double> <double 0x100000000, double 0x300000002>
24;
25  %tmp3 = bitcast <4 x i32> < i32 0, i32 1, i32 2, i32 3 > to <2 x double>
26  ret <2 x double> %tmp3
27}
28
29define <4 x float> @test4() {
30; CHECK-LABEL: @test4(
31; CHECK-NEXT:    ret <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0x36A0000000000000, float 0.000000e+00>
32;
33  %tmp3 = bitcast <2 x i64> < i64 0, i64 1 > to <4 x float>
34  ret <4 x float> %tmp3
35}
36
37define <2 x i64> @test5() {
38; CHECK-LABEL: @test5(
39; CHECK-NEXT:    ret <2 x i64> <i64 4575657221408423936, i64 4629700418010611712>
40;
41  %tmp3 = bitcast <4 x float> <float 0.0, float 1.0, float 2.0, float 3.0> to <2 x i64>
42  ret <2 x i64> %tmp3
43}
44
45define <4 x i32> @test6() {
46; CHECK-LABEL: @test6(
47; CHECK-NEXT:    ret <4 x i32> <i32 0, i32 1071644672, i32 0, i32 1072693248>
48;
49  %tmp3 = bitcast <2 x double> <double 0.5, double 1.0> to <4 x i32>
50  ret <4 x i32> %tmp3
51}
52
53define i32 @test7() {
54; CHECK-LABEL: @test7(
55; CHECK-NEXT:    ret i32 1118464
56;
57  %tmp3 = bitcast <2 x half> <half 0xH1100, half 0xH0011> to i32
58  ret i32 %tmp3
59}
60
61define <4 x i32> @test8(<1 x i64> %y) {
62; CHECK-LABEL: @test8(
63; CHECK-NEXT:    ret <4 x i32> zeroinitializer
64;
65  %c = bitcast <2 x i64> <i64 0, i64 0> to <4 x i32>
66  ret <4 x i32> %c
67}
68
69define <4 x i32> @test9(<1 x i64> %y) {
70; CHECK-LABEL: @test9(
71; CHECK-NEXT:    ret <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
72;
73  %c = bitcast <2 x i64> <i64 -1, i64 -1> to <4 x i32>
74  ret <4 x i32> %c
75}
76
77define <1 x i1> @test10() {
78; CHECK-LABEL: @test10(
79; CHECK-NEXT:    ret <1 x i1> <i1 icmp eq (i64 bitcast (<1 x double> <double 0xFFFFFFFFFFFFFFFF> to i64), i64 0)>
80;
81  %ret = icmp eq <1 x i64> <i64 bitcast (<1 x double> <double 0xFFFFFFFFFFFFFFFF> to i64)>, zeroinitializer
82  ret <1 x i1> %ret
83}
84
85; from MultiSource/Benchmarks/Bullet
86define <2 x float> @foo() {
87; CHECK-LABEL: @foo(
88; CHECK-NEXT:    ret <2 x float> <float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000>
89;
90  %cast = bitcast i64 -1 to <2 x float>
91  ret <2 x float> %cast
92}
93
94
95define <2 x double> @foo2() {
96; CHECK-LABEL: @foo2(
97; CHECK-NEXT:    ret <2 x double> <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>
98;
99  %cast = bitcast i128 -1 to <2 x double>
100  ret <2 x double> %cast
101}
102
103define <1 x float> @foo3() {
104; CHECK-LABEL: @foo3(
105; CHECK-NEXT:    ret <1 x float> <float 0xFFFFFFFFE0000000>
106;
107  %cast = bitcast i32 -1 to <1 x float>
108  ret <1 x float> %cast
109}
110
111define float @foo4() {
112; CHECK-LABEL: @foo4(
113; CHECK-NEXT:    ret float 0xFFFFFFFFE0000000
114;
115  %cast = bitcast <1 x i32 ><i32 -1> to float
116  ret float %cast
117}
118
119define double @foo5() {
120; CHECK-LABEL: @foo5(
121; CHECK-NEXT:    ret double 0xFFFFFFFFFFFFFFFF
122;
123  %cast = bitcast <2 x i32 ><i32 -1, i32 -1> to double
124  ret double %cast
125}
126
127define <2 x double> @foo6() {
128; CHECK-LABEL: @foo6(
129; CHECK-NEXT:    ret <2 x double> <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>
130;
131  %cast = bitcast <4 x i32><i32 -1, i32 -1, i32 -1, i32 -1> to <2 x double>
132  ret <2 x double> %cast
133}
134
135define <4 x i32> @bitcast_constexpr_4i32_2i64_u2() {
136; CHECK-LABEL: @bitcast_constexpr_4i32_2i64_u2(
137; CHECK-NEXT:    ret <4 x i32> <i32 undef, i32 undef, i32 2, i32 0>
138;
139  %cast = bitcast <2 x i64><i64 undef, i64 2> to <4 x i32>
140  ret <4 x i32> %cast
141}
142
143define <4 x i32> @bitcast_constexpr_4i32_2i64_1u() {
144; CHECK-LABEL: @bitcast_constexpr_4i32_2i64_1u(
145; CHECK-NEXT:    ret <4 x i32> <i32 1, i32 0, i32 undef, i32 undef>
146;
147  %cast = bitcast <2 x i64><i64 1, i64 undef> to <4 x i32>
148  ret <4 x i32> %cast
149}
150
151define <4 x i32> @bitcast_constexpr_4i32_2i64() {
152; CHECK-LABEL: @bitcast_constexpr_4i32_2i64(
153; CHECK-NEXT:    ret <4 x i32> <i32 undef, i32 undef, i32 2, i32 0>
154;
155  %cast = bitcast <2 x i64><i64 undef, i64 2> to <4 x i32>
156  ret <4 x i32> %cast
157}
158
159define <8 x i16> @bitcast_constexpr_8i16_2i64_u2() {
160; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_u2(
161; CHECK-NEXT:    ret <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 2, i16 0, i16 0, i16 0>
162;
163  %cast = bitcast <2 x i64><i64 undef, i64 2> to <8 x i16>
164  ret <8 x i16> %cast
165}
166
167define <8 x i16> @bitcast_constexpr_8i16_2i64_1u() {
168; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_1u(
169; CHECK-NEXT:    ret <8 x i16> <i16 1, i16 0, i16 0, i16 0, i16 undef, i16 undef, i16 undef, i16 undef>
170;
171  %cast = bitcast <2 x i64><i64 1, i64 undef> to <8 x i16>
172  ret <8 x i16> %cast
173}
174
175define <8 x i16> @bitcast_constexpr_8i16_2i64_u65536() {
176; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_u65536(
177; CHECK-NEXT:    ret <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 0, i16 1, i16 0, i16 0>
178;
179  %cast = bitcast <2 x i64><i64 undef, i64 65536> to <8 x i16>
180  ret <8 x i16> %cast
181}
182
183define <16 x i8> @bitcast_constexpr_16i8_2i64_u2() {
184; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_u2(
185; CHECK-NEXT:    ret <16 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 2, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>
186;
187  %cast = bitcast <2 x i64><i64 undef, i64 2> to <16 x i8>
188  ret <16 x i8> %cast
189}
190
191define <16 x i8> @bitcast_constexpr_16i8_2i64_256u() {
192; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_256u(
193; CHECK-NEXT:    ret <16 x i8> <i8 0, i8 1, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef>
194;
195  %cast = bitcast <2 x i64><i64 256, i64 undef> to <16 x i8>
196  ret <16 x i8> %cast
197}
198
199define <16 x i8> @bitcast_constexpr_16i8_2i64_u256() {
200; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_u256(
201; CHECK-NEXT:    ret <16 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 0, i8 1, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>
202;
203  %cast = bitcast <2 x i64><i64 undef, i64 256> to <16 x i8>
204  ret <16 x i8> %cast
205}
206
207define <8 x i16> @bitcast_constexpr_8i16_4i32_uu22() {
208; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_uu22(
209; CHECK-NEXT:    ret <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 2, i16 0, i16 2, i16 0>
210;
211  %cast = bitcast <4 x i32><i32 undef, i32 undef, i32 2, i32 2> to <8 x i16>
212  ret <8 x i16> %cast
213}
214
215define <8 x i16> @bitcast_constexpr_8i16_4i32_10uu() {
216; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_10uu(
217; CHECK-NEXT:    ret <8 x i16> <i16 1, i16 0, i16 0, i16 0, i16 undef, i16 undef, i16 undef, i16 undef>
218;
219  %cast = bitcast <4 x i32><i32 1, i32 0, i32 undef, i32 undef> to <8 x i16>
220  ret <8 x i16> %cast
221}
222
223define <8 x i16> @bitcast_constexpr_8i16_4i32_u257u256() {
224; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_u257u256(
225; CHECK-NEXT:    ret <8 x i16> <i16 undef, i16 undef, i16 0, i16 1, i16 undef, i16 undef, i16 0, i16 1>
226;
227  %cast = bitcast <4 x i32><i32 undef, i32 65536, i32 undef, i32 65536> to <8 x i16>
228  ret <8 x i16> %cast
229}
230
231define <16 x i8> @bitcast_constexpr_16i8_4i32_u2u2() {
232; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_u2u2(
233; CHECK-NEXT:    ret <16 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 2, i8 0, i8 0, i8 0, i8 undef, i8 undef, i8 undef, i8 undef, i8 2, i8 0, i8 0, i8 0>
234;
235  %cast = bitcast <4 x i32><i32 undef, i32 2, i32 undef, i32 2> to <16 x i8>
236  ret <16 x i8> %cast
237}
238
239define <16 x i8> @bitcast_constexpr_16i8_4i32_1u1u() {
240; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_1u1u(
241; CHECK-NEXT:    ret <16 x i8> <i8 1, i8 0, i8 0, i8 0, i8 undef, i8 undef, i8 undef, i8 undef, i8 1, i8 0, i8 0, i8 0, i8 undef, i8 undef, i8 undef, i8 undef>
242;
243  %cast = bitcast <4 x i32><i32 1, i32 undef, i32 1, i32 undef> to <16 x i8>
244  ret <16 x i8> %cast
245}
246
247define <16 x i8> @bitcast_constexpr_16i8_4i32_u256uu() {
248; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_u256uu(
249; CHECK-NEXT:    ret <16 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 0, i8 1, i8 0, i8 0, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef>
250;
251  %cast = bitcast <4 x i32><i32 undef, i32 256, i32 undef, i32 undef> to <16 x i8>
252  ret <16 x i8> %cast
253}
254
255define <16 x i8> @bitcast_constexpr_16i8_8i16_u2u2u2u2() {
256; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_u2u2u2u2(
257; CHECK-NEXT:    ret <16 x i8> <i8 undef, i8 undef, i8 2, i8 0, i8 undef, i8 undef, i8 2, i8 0, i8 undef, i8 undef, i8 2, i8 0, i8 undef, i8 undef, i8 2, i8 0>
258;
259  %cast = bitcast <8 x i16><i16 undef, i16 2, i16 undef, i16 2, i16 undef, i16 2, i16 undef, i16 2> to <16 x i8>
260  ret <16 x i8> %cast
261}
262
263define <16 x i8> @bitcast_constexpr_16i8_8i16_1u1u1u1u() {
264; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_1u1u1u1u(
265; CHECK-NEXT:    ret <16 x i8> <i8 1, i8 0, i8 undef, i8 undef, i8 1, i8 0, i8 undef, i8 undef, i8 1, i8 0, i8 undef, i8 undef, i8 1, i8 0, i8 undef, i8 undef>
266;
267  %cast = bitcast <8 x i16><i16 1, i16 undef, i16 1, i16 undef, i16 1, i16 undef, i16 1, i16 undef> to <16 x i8>
268  ret <16 x i8> %cast
269}
270
271define <16 x i8> @bitcast_constexpr_16i8_8i16_u256uuu256uu() {
272; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_u256uuu256uu(
273; CHECK-NEXT:    ret <16 x i8> <i8 undef, i8 undef, i8 0, i8 1, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 0, i8 1, i8 undef, i8 undef, i8 undef, i8 undef>
274;
275  %cast = bitcast <8 x i16><i16 undef, i16 256, i16 undef, i16 undef, i16 undef, i16 256, i16 undef, i16 undef> to <16 x i8>
276  ret <16 x i8> %cast
277}
278