1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-f64:32:64-v64:64:64-v128:128:128"
5 define <2 x i64> @test1() {
7 ; CHECK-NEXT: ret <2 x i64> <i64 4294967296, i64 12884901890>
9 %tmp3 = bitcast <4 x i32> < i32 0, i32 1, i32 2, i32 3 > to <2 x i64>
13 define <4 x i32> @test2() {
14 ; CHECK-LABEL: @test2(
15 ; CHECK-NEXT: ret <4 x i32> <i32 0, i32 0, i32 1, i32 0>
17 %tmp3 = bitcast <2 x i64> < i64 0, i64 1 > to <4 x i32>
21 define <2 x double> @test3() {
22 ; CHECK-LABEL: @test3(
23 ; CHECK-NEXT: ret <2 x double> <double 0x100000000, double 0x300000002>
25 %tmp3 = bitcast <4 x i32> < i32 0, i32 1, i32 2, i32 3 > to <2 x double>
26 ret <2 x double> %tmp3
29 define <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>
33 %tmp3 = bitcast <2 x i64> < i64 0, i64 1 > to <4 x float>
37 define <2 x i64> @test5() {
38 ; CHECK-LABEL: @test5(
39 ; CHECK-NEXT: ret <2 x i64> <i64 4575657221408423936, i64 4629700418010611712>
41 %tmp3 = bitcast <4 x float> <float 0.0, float 1.0, float 2.0, float 3.0> to <2 x i64>
45 define <4 x i32> @test6() {
46 ; CHECK-LABEL: @test6(
47 ; CHECK-NEXT: ret <4 x i32> <i32 0, i32 1071644672, i32 0, i32 1072693248>
49 %tmp3 = bitcast <2 x double> <double 0.5, double 1.0> to <4 x i32>
54 ; CHECK-LABEL: @test7(
55 ; CHECK-NEXT: ret i32 1118464
57 %tmp3 = bitcast <2 x half> <half 0xH1100, half 0xH0011> to i32
61 define <4 x i32> @test8(<1 x i64> %y) {
62 ; CHECK-LABEL: @test8(
63 ; CHECK-NEXT: ret <4 x i32> zeroinitializer
65 %c = bitcast <2 x i64> <i64 0, i64 0> to <4 x i32>
69 define <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>
73 %c = bitcast <2 x i64> <i64 -1, i64 -1> to <4 x i32>
77 define <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)>
81 %ret = icmp eq <1 x i64> <i64 bitcast (<1 x double> <double 0xFFFFFFFFFFFFFFFF> to i64)>, zeroinitializer
85 ; from MultiSource/Benchmarks/Bullet
86 define <2 x float> @foo() {
88 ; CHECK-NEXT: ret <2 x float> <float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000>
90 %cast = bitcast i64 -1 to <2 x float>
95 define <2 x double> @foo2() {
97 ; CHECK-NEXT: ret <2 x double> <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>
99 %cast = bitcast i128 -1 to <2 x double>
100 ret <2 x double> %cast
103 define <1 x float> @foo3() {
104 ; CHECK-LABEL: @foo3(
105 ; CHECK-NEXT: ret <1 x float> <float 0xFFFFFFFFE0000000>
107 %cast = bitcast i32 -1 to <1 x float>
108 ret <1 x float> %cast
111 define float @foo4() {
112 ; CHECK-LABEL: @foo4(
113 ; CHECK-NEXT: ret float 0xFFFFFFFFE0000000
115 %cast = bitcast <1 x i32 ><i32 -1> to float
119 define double @foo5() {
120 ; CHECK-LABEL: @foo5(
121 ; CHECK-NEXT: ret double 0xFFFFFFFFFFFFFFFF
123 %cast = bitcast <2 x i32 ><i32 -1, i32 -1> to double
127 define <2 x double> @foo6() {
128 ; CHECK-LABEL: @foo6(
129 ; CHECK-NEXT: ret <2 x double> <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>
131 %cast = bitcast <4 x i32><i32 -1, i32 -1, i32 -1, i32 -1> to <2 x double>
132 ret <2 x double> %cast
135 define <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>
139 %cast = bitcast <2 x i64><i64 undef, i64 2> to <4 x i32>
143 define <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>
147 %cast = bitcast <2 x i64><i64 1, i64 undef> to <4 x i32>
151 define <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>
155 %cast = bitcast <2 x i64><i64 undef, i64 2> to <4 x i32>
159 define <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>
163 %cast = bitcast <2 x i64><i64 undef, i64 2> to <8 x i16>
167 define <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>
171 %cast = bitcast <2 x i64><i64 1, i64 undef> to <8 x i16>
175 define <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>
179 %cast = bitcast <2 x i64><i64 undef, i64 65536> to <8 x i16>
183 define <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>
187 %cast = bitcast <2 x i64><i64 undef, i64 2> to <16 x i8>
191 define <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>
195 %cast = bitcast <2 x i64><i64 256, i64 undef> to <16 x i8>
199 define <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>
203 %cast = bitcast <2 x i64><i64 undef, i64 256> to <16 x i8>
207 define <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>
211 %cast = bitcast <4 x i32><i32 undef, i32 undef, i32 2, i32 2> to <8 x i16>
215 define <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>
219 %cast = bitcast <4 x i32><i32 1, i32 0, i32 undef, i32 undef> to <8 x i16>
223 define <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>
227 %cast = bitcast <4 x i32><i32 undef, i32 65536, i32 undef, i32 65536> to <8 x i16>
231 define <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>
235 %cast = bitcast <4 x i32><i32 undef, i32 2, i32 undef, i32 2> to <16 x i8>
239 define <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>
243 %cast = bitcast <4 x i32><i32 1, i32 undef, i32 1, i32 undef> to <16 x i8>
247 define <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>
251 %cast = bitcast <4 x i32><i32 undef, i32 256, i32 undef, i32 undef> to <16 x i8>
255 define <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>
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>
263 define <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>
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>
271 define <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>
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>