1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
3 ; RUN: opt < %s -passes=instsimplify -use-constant-fp-for-fixed-length-splat -use-constant-int-for-fixed-length-splat -S | FileCheck %s
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-f64:32:64-v64:64:64-v128:128:128"
6 define <2 x i64> @test1() {
8 ; CHECK-NEXT: ret <2 x i64> <i64 4294967296, i64 12884901890>
10 %tmp3 = bitcast <4 x i32> < i32 0, i32 1, i32 2, i32 3 > to <2 x i64>
14 define <4 x i32> @test2() {
15 ; CHECK-LABEL: @test2(
16 ; CHECK-NEXT: ret <4 x i32> <i32 0, i32 0, i32 1, i32 0>
18 %tmp3 = bitcast <2 x i64> < i64 0, i64 1 > to <4 x i32>
22 define <2 x double> @test3() {
23 ; CHECK-LABEL: @test3(
24 ; CHECK-NEXT: ret <2 x double> <double 0x100000000, double 0x300000002>
26 %tmp3 = bitcast <4 x i32> < i32 0, i32 1, i32 2, i32 3 > to <2 x double>
27 ret <2 x double> %tmp3
30 define <4 x float> @test4() {
31 ; CHECK-LABEL: @test4(
32 ; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0x36A0000000000000, float 0.000000e+00>
34 %tmp3 = bitcast <2 x i64> < i64 0, i64 1 > to <4 x float>
38 define <2 x i64> @test5() {
39 ; CHECK-LABEL: @test5(
40 ; CHECK-NEXT: ret <2 x i64> <i64 4575657221408423936, i64 4629700418010611712>
42 %tmp3 = bitcast <4 x float> <float 0.0, float 1.0, float 2.0, float 3.0> to <2 x i64>
46 define <4 x i32> @test6() {
47 ; CHECK-LABEL: @test6(
48 ; CHECK-NEXT: ret <4 x i32> <i32 0, i32 1071644672, i32 0, i32 1072693248>
50 %tmp3 = bitcast <2 x double> <double 0.5, double 1.0> to <4 x i32>
55 ; CHECK-LABEL: @test7(
56 ; CHECK-NEXT: ret i32 1118464
58 %tmp3 = bitcast <2 x half> <half 0xH1100, half 0xH0011> to i32
62 define <4 x i32> @test8(<1 x i64> %y) {
63 ; CHECK-LABEL: @test8(
64 ; CHECK-NEXT: ret <4 x i32> zeroinitializer
66 %c = bitcast <2 x i64> <i64 0, i64 0> to <4 x i32>
70 define <4 x i32> @test9(<1 x i64> %y) {
71 ; CHECK-LABEL: @test9(
72 ; CHECK-NEXT: ret <4 x i32> splat (i32 -1)
74 %c = bitcast <2 x i64> <i64 -1, i64 -1> to <4 x i32>
78 define <1 x i1> @test10() {
79 ; CHECK-LABEL: @test10(
80 ; CHECK-NEXT: ret <1 x i1> zeroinitializer
82 %ret = icmp eq <1 x i64> <i64 bitcast (<1 x double> <double 0xFFFFFFFFFFFFFFFF> to i64)>, zeroinitializer
86 ; from MultiSource/Benchmarks/Bullet
87 define <2 x float> @foo() {
89 ; CHECK-NEXT: ret <2 x float> splat (float 0xFFFFFFFFE0000000)
91 %cast = bitcast i64 -1 to <2 x float>
96 define <2 x double> @foo2() {
98 ; CHECK-NEXT: ret <2 x double> splat (double 0xFFFFFFFFFFFFFFFF)
100 %cast = bitcast i128 -1 to <2 x double>
101 ret <2 x double> %cast
104 define <1 x float> @foo3() {
105 ; CHECK-LABEL: @foo3(
106 ; CHECK-NEXT: ret <1 x float> splat (float 0xFFFFFFFFE0000000)
108 %cast = bitcast i32 -1 to <1 x float>
109 ret <1 x float> %cast
112 define float @foo4() {
113 ; CHECK-LABEL: @foo4(
114 ; CHECK-NEXT: ret float 0xFFFFFFFFE0000000
116 %cast = bitcast <1 x i32 ><i32 -1> to float
120 define double @foo5() {
121 ; CHECK-LABEL: @foo5(
122 ; CHECK-NEXT: ret double 0xFFFFFFFFFFFFFFFF
124 %cast = bitcast <2 x i32 ><i32 -1, i32 -1> to double
128 define <2 x double> @foo6() {
129 ; CHECK-LABEL: @foo6(
130 ; CHECK-NEXT: ret <2 x double> splat (double 0xFFFFFFFFFFFFFFFF)
132 %cast = bitcast <4 x i32><i32 -1, i32 -1, i32 -1, i32 -1> to <2 x double>
133 ret <2 x double> %cast
136 define <4 x i32> @bitcast_constexpr_4i32_2i64_u2() {
137 ; CHECK-LABEL: @bitcast_constexpr_4i32_2i64_u2(
138 ; CHECK-NEXT: ret <4 x i32> <i32 undef, i32 undef, i32 2, i32 0>
140 %cast = bitcast <2 x i64><i64 undef, i64 2> to <4 x i32>
144 define <4 x i32> @bitcast_constexpr_4i32_2i64_1u() {
145 ; CHECK-LABEL: @bitcast_constexpr_4i32_2i64_1u(
146 ; CHECK-NEXT: ret <4 x i32> <i32 1, i32 0, i32 undef, i32 undef>
148 %cast = bitcast <2 x i64><i64 1, i64 undef> to <4 x i32>
152 define <4 x i32> @bitcast_constexpr_4i32_2i64() {
153 ; CHECK-LABEL: @bitcast_constexpr_4i32_2i64(
154 ; CHECK-NEXT: ret <4 x i32> <i32 undef, i32 undef, i32 2, i32 0>
156 %cast = bitcast <2 x i64><i64 undef, i64 2> to <4 x i32>
160 define <8 x i16> @bitcast_constexpr_8i16_2i64_u2() {
161 ; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_u2(
162 ; CHECK-NEXT: ret <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 2, i16 0, i16 0, i16 0>
164 %cast = bitcast <2 x i64><i64 undef, i64 2> to <8 x i16>
168 define <8 x i16> @bitcast_constexpr_8i16_2i64_1u() {
169 ; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_1u(
170 ; CHECK-NEXT: ret <8 x i16> <i16 1, i16 0, i16 0, i16 0, i16 undef, i16 undef, i16 undef, i16 undef>
172 %cast = bitcast <2 x i64><i64 1, i64 undef> to <8 x i16>
176 define <8 x i16> @bitcast_constexpr_8i16_2i64_u65536() {
177 ; CHECK-LABEL: @bitcast_constexpr_8i16_2i64_u65536(
178 ; CHECK-NEXT: ret <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 0, i16 1, i16 0, i16 0>
180 %cast = bitcast <2 x i64><i64 undef, i64 65536> to <8 x i16>
184 define <16 x i8> @bitcast_constexpr_16i8_2i64_u2() {
185 ; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_u2(
186 ; 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>
188 %cast = bitcast <2 x i64><i64 undef, i64 2> to <16 x i8>
192 define <16 x i8> @bitcast_constexpr_16i8_2i64_256u() {
193 ; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_256u(
194 ; 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>
196 %cast = bitcast <2 x i64><i64 256, i64 undef> to <16 x i8>
200 define <16 x i8> @bitcast_constexpr_16i8_2i64_u256() {
201 ; CHECK-LABEL: @bitcast_constexpr_16i8_2i64_u256(
202 ; 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>
204 %cast = bitcast <2 x i64><i64 undef, i64 256> to <16 x i8>
208 define <8 x i16> @bitcast_constexpr_8i16_4i32_uu22() {
209 ; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_uu22(
210 ; CHECK-NEXT: ret <8 x i16> <i16 undef, i16 undef, i16 undef, i16 undef, i16 2, i16 0, i16 2, i16 0>
212 %cast = bitcast <4 x i32><i32 undef, i32 undef, i32 2, i32 2> to <8 x i16>
216 define <8 x i16> @bitcast_constexpr_8i16_4i32_10uu() {
217 ; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_10uu(
218 ; CHECK-NEXT: ret <8 x i16> <i16 1, i16 0, i16 0, i16 0, i16 undef, i16 undef, i16 undef, i16 undef>
220 %cast = bitcast <4 x i32><i32 1, i32 0, i32 undef, i32 undef> to <8 x i16>
224 define <8 x i16> @bitcast_constexpr_8i16_4i32_u257u256() {
225 ; CHECK-LABEL: @bitcast_constexpr_8i16_4i32_u257u256(
226 ; CHECK-NEXT: ret <8 x i16> <i16 undef, i16 undef, i16 0, i16 1, i16 undef, i16 undef, i16 0, i16 1>
228 %cast = bitcast <4 x i32><i32 undef, i32 65536, i32 undef, i32 65536> to <8 x i16>
232 define <16 x i8> @bitcast_constexpr_16i8_4i32_u2u2() {
233 ; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_u2u2(
234 ; 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>
236 %cast = bitcast <4 x i32><i32 undef, i32 2, i32 undef, i32 2> to <16 x i8>
240 define <16 x i8> @bitcast_constexpr_16i8_4i32_1u1u() {
241 ; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_1u1u(
242 ; 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>
244 %cast = bitcast <4 x i32><i32 1, i32 undef, i32 1, i32 undef> to <16 x i8>
248 define <16 x i8> @bitcast_constexpr_16i8_4i32_u256uu() {
249 ; CHECK-LABEL: @bitcast_constexpr_16i8_4i32_u256uu(
250 ; 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>
252 %cast = bitcast <4 x i32><i32 undef, i32 256, i32 undef, i32 undef> to <16 x i8>
256 define <16 x i8> @bitcast_constexpr_16i8_8i16_u2u2u2u2() {
257 ; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_u2u2u2u2(
258 ; 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>
260 %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>
264 define <16 x i8> @bitcast_constexpr_16i8_8i16_1u1u1u1u() {
265 ; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_1u1u1u1u(
266 ; 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>
268 %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>
272 define <16 x i8> @bitcast_constexpr_16i8_8i16_u256uuu256uu() {
273 ; CHECK-LABEL: @bitcast_constexpr_16i8_8i16_u256uuu256uu(
274 ; 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>
276 %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>
280 define <1 x i32> @bitcast_constexpr_scalar_fp_to_vector_int() {
281 ; CHECK-LABEL: @bitcast_constexpr_scalar_fp_to_vector_int(
282 ; CHECK-NEXT: ret <1 x i32> splat (i32 1065353216)
284 %res = bitcast float 1.0 to <1 x i32>
288 define <2 x i64> @bitcast_constexpr_4f32_2i64_1111() {
289 ; CHECK-LABEL: @bitcast_constexpr_4f32_2i64_1111(
290 ; CHECK-NEXT: ret <2 x i64> splat (i64 4575657222473777152)
292 %res = bitcast <4 x float> splat (float 1.0) to <2 x i64>