blob: dde31749392b9b87f69f004fffdb2eeddcef32b7 [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
Roman Lebedev6ab60352018-03-14 17:31:03 +00004; This is related to https://bugs.llvm.org/show_bug.cgi?id=36682
5
6; FIXME: *all* of these are true tests.
7; In *all* of these, uitofp and bitcast should be instcombine'd out.
8
Roman Lebedeve6da3062018-03-18 15:53:02 +00009; FIXME: icmp eq/ne does not ignore undef elements in vectors.
10
Roman Lebedev6ab60352018-03-14 17:31:03 +000011define i1 @i32_cast_cmp_eq_int_0_uitofp_float(i32 %i) {
12; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float(
Roman Lebedeve6da3062018-03-18 15:53:02 +000013; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
Roman Lebedev6ab60352018-03-14 17:31:03 +000014; CHECK-NEXT: ret i1 [[CMP]]
15;
16 %f = uitofp i32 %i to float
17 %b = bitcast float %f to i32
18 %cmp = icmp eq i32 %b, 0
19 ret i1 %cmp
20}
21
22define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec(<2 x i32> %i) {
23; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec(
Roman Lebedeve6da3062018-03-18 15:53:02 +000024; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer
Roman Lebedev6ab60352018-03-14 17:31:03 +000025; CHECK-NEXT: ret <2 x i1> [[CMP]]
26;
27 %f = uitofp <2 x i32> %i to <2 x float>
28 %b = bitcast <2 x float> %f to <2 x i32>
29 %cmp = icmp eq <2 x i32> %b, <i32 0, i32 0>
30 ret <2 x i1> %cmp
31}
32
33define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(<3 x i32> %i) {
34; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(
35; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x float>
36; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <3 x i32>
37; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[B]], <i32 0, i32 undef, i32 0>
38; CHECK-NEXT: ret <3 x i1> [[CMP]]
39;
40 %f = uitofp <3 x i32> %i to <3 x float>
41 %b = bitcast <3 x float> %f to <3 x i32>
42 %cmp = icmp eq <3 x i32> %b, <i32 0, i32 undef, i32 0>
43 ret <3 x i1> %cmp
44}
45
46define i1 @i32_cast_cmp_ne_int_0_uitofp_float(i32 %i) {
47; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float(
Roman Lebedeve6da3062018-03-18 15:53:02 +000048; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
Roman Lebedev6ab60352018-03-14 17:31:03 +000049; CHECK-NEXT: ret i1 [[CMP]]
50;
51 %f = uitofp i32 %i to float
52 %b = bitcast float %f to i32
53 %cmp = icmp ne i32 %b, 0
54 ret i1 %cmp
55}
56
57define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec(<2 x i32> %i) {
58; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec(
Roman Lebedeve6da3062018-03-18 15:53:02 +000059; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer
Roman Lebedev6ab60352018-03-14 17:31:03 +000060; CHECK-NEXT: ret <2 x i1> [[CMP]]
61;
62 %f = uitofp <2 x i32> %i to <2 x float>
63 %b = bitcast <2 x float> %f to <2 x i32>
64 %cmp = icmp ne <2 x i32> %b, <i32 0, i32 0>
65 ret <2 x i1> %cmp
66}
67
68define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(<3 x i32> %i) {
69; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(
70; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x float>
71; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <3 x i32>
72; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[B]], <i32 0, i32 undef, i32 0>
73; CHECK-NEXT: ret <3 x i1> [[CMP]]
74;
75 %f = uitofp <3 x i32> %i to <3 x float>
76 %b = bitcast <3 x float> %f to <3 x i32>
77 %cmp = icmp ne <3 x i32> %b, <i32 0, i32 undef, i32 0>
78 ret <3 x i1> %cmp
79}
80
81define i1 @i32_cast_cmp_eq_int_0_uitofp_double(i32 %i) {
82; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double(
Roman Lebedeve6da3062018-03-18 15:53:02 +000083; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
Roman Lebedev6ab60352018-03-14 17:31:03 +000084; CHECK-NEXT: ret i1 [[CMP]]
85;
86 %f = uitofp i32 %i to double
87 %b = bitcast double %f to i64
88 %cmp = icmp eq i64 %b, 0
89 ret i1 %cmp
90}
91
92define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec(<2 x i32> %i) {
93; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec(
Roman Lebedeve6da3062018-03-18 15:53:02 +000094; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer
Roman Lebedev6ab60352018-03-14 17:31:03 +000095; CHECK-NEXT: ret <2 x i1> [[CMP]]
96;
97 %f = uitofp <2 x i32> %i to <2 x double>
98 %b = bitcast <2 x double> %f to <2 x i64>
99 %cmp = icmp eq <2 x i64> %b, <i64 0, i64 0>
100 ret <2 x i1> %cmp
101}
102
103define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(<3 x i32> %i) {
104; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(
105; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x double>
106; CHECK-NEXT: [[B:%.*]] = bitcast <3 x double> [[F]] to <3 x i64>
107; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i64> [[B]], <i64 0, i64 undef, i64 0>
108; CHECK-NEXT: ret <3 x i1> [[CMP]]
109;
110 %f = uitofp <3 x i32> %i to <3 x double>
111 %b = bitcast <3 x double> %f to <3 x i64>
112 %cmp = icmp eq <3 x i64> %b, <i64 0, i64 undef, i64 0>
113 ret <3 x i1> %cmp
114}
115
116define i1 @i32_cast_cmp_ne_int_0_uitofp_double(i32 %i) {
117; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double(
Roman Lebedeve6da3062018-03-18 15:53:02 +0000118; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
Roman Lebedev6ab60352018-03-14 17:31:03 +0000119; CHECK-NEXT: ret i1 [[CMP]]
120;
121 %f = uitofp i32 %i to double
122 %b = bitcast double %f to i64
123 %cmp = icmp ne i64 %b, 0
124 ret i1 %cmp
125}
126
127define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec(<2 x i32> %i) {
128; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec(
Roman Lebedeve6da3062018-03-18 15:53:02 +0000129; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer
Roman Lebedev6ab60352018-03-14 17:31:03 +0000130; CHECK-NEXT: ret <2 x i1> [[CMP]]
131;
132 %f = uitofp <2 x i32> %i to <2 x double>
133 %b = bitcast <2 x double> %f to <2 x i64>
134 %cmp = icmp ne <2 x i64> %b, <i64 0, i64 0>
135 ret <2 x i1> %cmp
136}
137
138define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(<3 x i32> %i) {
139; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(
140; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x double>
141; CHECK-NEXT: [[B:%.*]] = bitcast <3 x double> [[F]] to <3 x i64>
142; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i64> [[B]], <i64 0, i64 undef, i64 0>
143; CHECK-NEXT: ret <3 x i1> [[CMP]]
144;
145 %f = uitofp <3 x i32> %i to <3 x double>
146 %b = bitcast <3 x double> %f to <3 x i64>
147 %cmp = icmp ne <3 x i64> %b, <i64 0, i64 undef, i64 0>
148 ret <3 x i1> %cmp
149}
150
151define i1 @i32_cast_cmp_eq_int_0_uitofp_half(i32 %i) {
152; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half(
Roman Lebedeve6da3062018-03-18 15:53:02 +0000153; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
Roman Lebedev6ab60352018-03-14 17:31:03 +0000154; CHECK-NEXT: ret i1 [[CMP]]
155;
156 %f = uitofp i32 %i to half
157 %b = bitcast half %f to i16
158 %cmp = icmp eq i16 %b, 0
159 ret i1 %cmp
160}
161
162define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec(<2 x i32> %i) {
163; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec(
Roman Lebedeve6da3062018-03-18 15:53:02 +0000164; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer
Roman Lebedev6ab60352018-03-14 17:31:03 +0000165; CHECK-NEXT: ret <2 x i1> [[CMP]]
166;
167 %f = uitofp <2 x i32> %i to <2 x half>
168 %b = bitcast <2 x half> %f to <2 x i16>
169 %cmp = icmp eq <2 x i16> %b, <i16 0, i16 0>
170 ret <2 x i1> %cmp
171}
172
173define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(<3 x i32> %i) {
174; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(
175; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x half>
176; CHECK-NEXT: [[B:%.*]] = bitcast <3 x half> [[F]] to <3 x i16>
177; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i16> [[B]], <i16 0, i16 undef, i16 0>
178; CHECK-NEXT: ret <3 x i1> [[CMP]]
179;
180 %f = uitofp <3 x i32> %i to <3 x half>
181 %b = bitcast <3 x half> %f to <3 x i16>
182 %cmp = icmp eq <3 x i16> %b, <i16 0, i16 undef, i16 0>
183 ret <3 x i1> %cmp
184}
185
186define i1 @i32_cast_cmp_ne_int_0_uitofp_half(i32 %i) {
187; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half(
Roman Lebedeve6da3062018-03-18 15:53:02 +0000188; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
Roman Lebedev6ab60352018-03-14 17:31:03 +0000189; CHECK-NEXT: ret i1 [[CMP]]
190;
191 %f = uitofp i32 %i to half
192 %b = bitcast half %f to i16
193 %cmp = icmp ne i16 %b, 0
194 ret i1 %cmp
195}
196
197define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec(<2 x i32> %i) {
198; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec(
Roman Lebedeve6da3062018-03-18 15:53:02 +0000199; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer
Roman Lebedev6ab60352018-03-14 17:31:03 +0000200; CHECK-NEXT: ret <2 x i1> [[CMP]]
201;
202 %f = uitofp <2 x i32> %i to <2 x half>
203 %b = bitcast <2 x half> %f to <2 x i16>
204 %cmp = icmp ne <2 x i16> %b, <i16 0, i16 0>
205 ret <2 x i1> %cmp
206}
207
208define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(<3 x i32> %i) {
209; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(
210; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x half>
211; CHECK-NEXT: [[B:%.*]] = bitcast <3 x half> [[F]] to <3 x i16>
212; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i16> [[B]], <i16 0, i16 undef, i16 0>
213; CHECK-NEXT: ret <3 x i1> [[CMP]]
214;
215 %f = uitofp <3 x i32> %i to <3 x half>
216 %b = bitcast <3 x half> %f to <3 x i16>
217 %cmp = icmp ne <3 x i16> %b, <i16 0, i16 undef, i16 0>
218 ret <3 x i1> %cmp
219}