blob: f54388377bc092dcbaf2880f8112e60cbc86488e [file] [log] [blame]
Roman Lebedev6ab60352018-03-14 17:31:03 +00001; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -S | FileCheck %s
3
4; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5
6; This is related to https://bugs.llvm.org/show_bug.cgi?id=36682
7
8; FIXME: *all* of these are true tests.
9; In *all* of these, uitofp and bitcast should be instcombine'd out.
10
11define i1 @i32_cast_cmp_eq_int_0_uitofp_float(i32 %i) {
12; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float(
13; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[I:%.*]] to float
14; CHECK-NEXT: [[B:%.*]] = bitcast float [[F]] to i32
15; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[B]], 0
16; CHECK-NEXT: ret i1 [[CMP]]
17;
18 %f = uitofp i32 %i to float
19 %b = bitcast float %f to i32
20 %cmp = icmp eq i32 %b, 0
21 ret i1 %cmp
22}
23
24define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec(<2 x i32> %i) {
25; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec(
26; CHECK-NEXT: [[F:%.*]] = uitofp <2 x i32> [[I:%.*]] to <2 x float>
27; CHECK-NEXT: [[B:%.*]] = bitcast <2 x float> [[F]] to <2 x i32>
28; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[B]], zeroinitializer
29; CHECK-NEXT: ret <2 x i1> [[CMP]]
30;
31 %f = uitofp <2 x i32> %i to <2 x float>
32 %b = bitcast <2 x float> %f to <2 x i32>
33 %cmp = icmp eq <2 x i32> %b, <i32 0, i32 0>
34 ret <2 x i1> %cmp
35}
36
37define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(<3 x i32> %i) {
38; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(
39; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x float>
40; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <3 x i32>
41; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[B]], <i32 0, i32 undef, i32 0>
42; CHECK-NEXT: ret <3 x i1> [[CMP]]
43;
44 %f = uitofp <3 x i32> %i to <3 x float>
45 %b = bitcast <3 x float> %f to <3 x i32>
46 %cmp = icmp eq <3 x i32> %b, <i32 0, i32 undef, i32 0>
47 ret <3 x i1> %cmp
48}
49
50define i1 @i32_cast_cmp_ne_int_0_uitofp_float(i32 %i) {
51; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float(
52; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[I:%.*]] to float
53; CHECK-NEXT: [[B:%.*]] = bitcast float [[F]] to i32
54; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[B]], 0
55; CHECK-NEXT: ret i1 [[CMP]]
56;
57 %f = uitofp i32 %i to float
58 %b = bitcast float %f to i32
59 %cmp = icmp ne i32 %b, 0
60 ret i1 %cmp
61}
62
63define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec(<2 x i32> %i) {
64; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec(
65; CHECK-NEXT: [[F:%.*]] = uitofp <2 x i32> [[I:%.*]] to <2 x float>
66; CHECK-NEXT: [[B:%.*]] = bitcast <2 x float> [[F]] to <2 x i32>
67; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer
68; CHECK-NEXT: ret <2 x i1> [[CMP]]
69;
70 %f = uitofp <2 x i32> %i to <2 x float>
71 %b = bitcast <2 x float> %f to <2 x i32>
72 %cmp = icmp ne <2 x i32> %b, <i32 0, i32 0>
73 ret <2 x i1> %cmp
74}
75
76define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(<3 x i32> %i) {
77; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(
78; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x float>
79; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <3 x i32>
80; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[B]], <i32 0, i32 undef, i32 0>
81; CHECK-NEXT: ret <3 x i1> [[CMP]]
82;
83 %f = uitofp <3 x i32> %i to <3 x float>
84 %b = bitcast <3 x float> %f to <3 x i32>
85 %cmp = icmp ne <3 x i32> %b, <i32 0, i32 undef, i32 0>
86 ret <3 x i1> %cmp
87}
88
89define i1 @i32_cast_cmp_eq_int_0_uitofp_double(i32 %i) {
90; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double(
91; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[I:%.*]] to double
92; CHECK-NEXT: [[B:%.*]] = bitcast double [[F]] to i64
93; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[B]], 0
94; CHECK-NEXT: ret i1 [[CMP]]
95;
96 %f = uitofp i32 %i to double
97 %b = bitcast double %f to i64
98 %cmp = icmp eq i64 %b, 0
99 ret i1 %cmp
100}
101
102define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec(<2 x i32> %i) {
103; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec(
104; CHECK-NEXT: [[F:%.*]] = uitofp <2 x i32> [[I:%.*]] to <2 x double>
105; CHECK-NEXT: [[B:%.*]] = bitcast <2 x double> [[F]] to <2 x i64>
106; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i64> [[B]], zeroinitializer
107; CHECK-NEXT: ret <2 x i1> [[CMP]]
108;
109 %f = uitofp <2 x i32> %i to <2 x double>
110 %b = bitcast <2 x double> %f to <2 x i64>
111 %cmp = icmp eq <2 x i64> %b, <i64 0, i64 0>
112 ret <2 x i1> %cmp
113}
114
115define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(<3 x i32> %i) {
116; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(
117; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x double>
118; CHECK-NEXT: [[B:%.*]] = bitcast <3 x double> [[F]] to <3 x i64>
119; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i64> [[B]], <i64 0, i64 undef, i64 0>
120; CHECK-NEXT: ret <3 x i1> [[CMP]]
121;
122 %f = uitofp <3 x i32> %i to <3 x double>
123 %b = bitcast <3 x double> %f to <3 x i64>
124 %cmp = icmp eq <3 x i64> %b, <i64 0, i64 undef, i64 0>
125 ret <3 x i1> %cmp
126}
127
128define i1 @i32_cast_cmp_ne_int_0_uitofp_double(i32 %i) {
129; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double(
130; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[I:%.*]] to double
131; CHECK-NEXT: [[B:%.*]] = bitcast double [[F]] to i64
132; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[B]], 0
133; CHECK-NEXT: ret i1 [[CMP]]
134;
135 %f = uitofp i32 %i to double
136 %b = bitcast double %f to i64
137 %cmp = icmp ne i64 %b, 0
138 ret i1 %cmp
139}
140
141define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec(<2 x i32> %i) {
142; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec(
143; CHECK-NEXT: [[F:%.*]] = uitofp <2 x i32> [[I:%.*]] to <2 x double>
144; CHECK-NEXT: [[B:%.*]] = bitcast <2 x double> [[F]] to <2 x i64>
145; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i64> [[B]], zeroinitializer
146; CHECK-NEXT: ret <2 x i1> [[CMP]]
147;
148 %f = uitofp <2 x i32> %i to <2 x double>
149 %b = bitcast <2 x double> %f to <2 x i64>
150 %cmp = icmp ne <2 x i64> %b, <i64 0, i64 0>
151 ret <2 x i1> %cmp
152}
153
154define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(<3 x i32> %i) {
155; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(
156; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x double>
157; CHECK-NEXT: [[B:%.*]] = bitcast <3 x double> [[F]] to <3 x i64>
158; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i64> [[B]], <i64 0, i64 undef, i64 0>
159; CHECK-NEXT: ret <3 x i1> [[CMP]]
160;
161 %f = uitofp <3 x i32> %i to <3 x double>
162 %b = bitcast <3 x double> %f to <3 x i64>
163 %cmp = icmp ne <3 x i64> %b, <i64 0, i64 undef, i64 0>
164 ret <3 x i1> %cmp
165}
166
167define i1 @i32_cast_cmp_eq_int_0_uitofp_half(i32 %i) {
168; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half(
169; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[I:%.*]] to half
170; CHECK-NEXT: [[B:%.*]] = bitcast half [[F]] to i16
171; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[B]], 0
172; CHECK-NEXT: ret i1 [[CMP]]
173;
174 %f = uitofp i32 %i to half
175 %b = bitcast half %f to i16
176 %cmp = icmp eq i16 %b, 0
177 ret i1 %cmp
178}
179
180define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec(<2 x i32> %i) {
181; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec(
182; CHECK-NEXT: [[F:%.*]] = uitofp <2 x i32> [[I:%.*]] to <2 x half>
183; CHECK-NEXT: [[B:%.*]] = bitcast <2 x half> [[F]] to <2 x i16>
184; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i16> [[B]], zeroinitializer
185; CHECK-NEXT: ret <2 x i1> [[CMP]]
186;
187 %f = uitofp <2 x i32> %i to <2 x half>
188 %b = bitcast <2 x half> %f to <2 x i16>
189 %cmp = icmp eq <2 x i16> %b, <i16 0, i16 0>
190 ret <2 x i1> %cmp
191}
192
193define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(<3 x i32> %i) {
194; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(
195; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x half>
196; CHECK-NEXT: [[B:%.*]] = bitcast <3 x half> [[F]] to <3 x i16>
197; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i16> [[B]], <i16 0, i16 undef, i16 0>
198; CHECK-NEXT: ret <3 x i1> [[CMP]]
199;
200 %f = uitofp <3 x i32> %i to <3 x half>
201 %b = bitcast <3 x half> %f to <3 x i16>
202 %cmp = icmp eq <3 x i16> %b, <i16 0, i16 undef, i16 0>
203 ret <3 x i1> %cmp
204}
205
206define i1 @i32_cast_cmp_ne_int_0_uitofp_half(i32 %i) {
207; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half(
208; CHECK-NEXT: [[F:%.*]] = uitofp i32 [[I:%.*]] to half
209; CHECK-NEXT: [[B:%.*]] = bitcast half [[F]] to i16
210; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[B]], 0
211; CHECK-NEXT: ret i1 [[CMP]]
212;
213 %f = uitofp i32 %i to half
214 %b = bitcast half %f to i16
215 %cmp = icmp ne i16 %b, 0
216 ret i1 %cmp
217}
218
219define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec(<2 x i32> %i) {
220; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec(
221; CHECK-NEXT: [[F:%.*]] = uitofp <2 x i32> [[I:%.*]] to <2 x half>
222; CHECK-NEXT: [[B:%.*]] = bitcast <2 x half> [[F]] to <2 x i16>
223; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i16> [[B]], zeroinitializer
224; CHECK-NEXT: ret <2 x i1> [[CMP]]
225;
226 %f = uitofp <2 x i32> %i to <2 x half>
227 %b = bitcast <2 x half> %f to <2 x i16>
228 %cmp = icmp ne <2 x i16> %b, <i16 0, i16 0>
229 ret <2 x i1> %cmp
230}
231
232define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(<3 x i32> %i) {
233; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(
234; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x half>
235; CHECK-NEXT: [[B:%.*]] = bitcast <3 x half> [[F]] to <3 x i16>
236; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i16> [[B]], <i16 0, i16 undef, i16 0>
237; CHECK-NEXT: ret <3 x i1> [[CMP]]
238;
239 %f = uitofp <3 x i32> %i to <3 x half>
240 %b = bitcast <3 x half> %f to <3 x i16>
241 %cmp = icmp ne <3 x i16> %b, <i16 0, i16 undef, i16 0>
242 ret <3 x i1> %cmp
243}