1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 ; This is related to https://bugs.llvm.org/show_bug.cgi?id=36682
6 ; In *all* of these, uitofp and bitcast should be instcombine'd out.
8 define i1 @i32_cast_cmp_eq_int_0_uitofp_float(i32 %i) {
9 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float(
10 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
11 ; CHECK-NEXT: ret i1 [[CMP]]
13 %f = uitofp i32 %i to float
14 %b = bitcast float %f to i32
15 %cmp = icmp eq i32 %b, 0
19 define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec(<2 x i32> %i) {
20 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec(
21 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer
22 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
24 %f = uitofp <2 x i32> %i to <2 x float>
25 %b = bitcast <2 x float> %f to <2 x i32>
26 %cmp = icmp eq <2 x i32> %b, <i32 0, i32 0>
30 define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(<3 x i32> %i) {
31 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(
32 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[I:%.*]], zeroinitializer
33 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
35 %f = uitofp <3 x i32> %i to <3 x float>
36 %b = bitcast <3 x float> %f to <3 x i32>
37 %cmp = icmp eq <3 x i32> %b, <i32 0, i32 undef, i32 0>
41 define i1 @i32_cast_cmp_ne_int_0_uitofp_float(i32 %i) {
42 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float(
43 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
44 ; CHECK-NEXT: ret i1 [[CMP]]
46 %f = uitofp i32 %i to float
47 %b = bitcast float %f to i32
48 %cmp = icmp ne i32 %b, 0
52 define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec(<2 x i32> %i) {
53 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec(
54 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer
55 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
57 %f = uitofp <2 x i32> %i to <2 x float>
58 %b = bitcast <2 x float> %f to <2 x i32>
59 %cmp = icmp ne <2 x i32> %b, <i32 0, i32 0>
63 define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(<3 x i32> %i) {
64 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(
65 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[I:%.*]], zeroinitializer
66 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
68 %f = uitofp <3 x i32> %i to <3 x float>
69 %b = bitcast <3 x float> %f to <3 x i32>
70 %cmp = icmp ne <3 x i32> %b, <i32 0, i32 undef, i32 0>
74 define i1 @i32_cast_cmp_eq_int_0_uitofp_double(i32 %i) {
75 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double(
76 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
77 ; CHECK-NEXT: ret i1 [[CMP]]
79 %f = uitofp i32 %i to double
80 %b = bitcast double %f to i64
81 %cmp = icmp eq i64 %b, 0
85 define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec(<2 x i32> %i) {
86 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec(
87 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer
88 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
90 %f = uitofp <2 x i32> %i to <2 x double>
91 %b = bitcast <2 x double> %f to <2 x i64>
92 %cmp = icmp eq <2 x i64> %b, <i64 0, i64 0>
96 define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(<3 x i32> %i) {
97 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(
98 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[I:%.*]], zeroinitializer
99 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
101 %f = uitofp <3 x i32> %i to <3 x double>
102 %b = bitcast <3 x double> %f to <3 x i64>
103 %cmp = icmp eq <3 x i64> %b, <i64 0, i64 undef, i64 0>
107 define i1 @i32_cast_cmp_ne_int_0_uitofp_double(i32 %i) {
108 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double(
109 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
110 ; CHECK-NEXT: ret i1 [[CMP]]
112 %f = uitofp i32 %i to double
113 %b = bitcast double %f to i64
114 %cmp = icmp ne i64 %b, 0
118 define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec(<2 x i32> %i) {
119 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec(
120 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer
121 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
123 %f = uitofp <2 x i32> %i to <2 x double>
124 %b = bitcast <2 x double> %f to <2 x i64>
125 %cmp = icmp ne <2 x i64> %b, <i64 0, i64 0>
129 define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(<3 x i32> %i) {
130 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(
131 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[I:%.*]], zeroinitializer
132 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
134 %f = uitofp <3 x i32> %i to <3 x double>
135 %b = bitcast <3 x double> %f to <3 x i64>
136 %cmp = icmp ne <3 x i64> %b, <i64 0, i64 undef, i64 0>
140 define i1 @i32_cast_cmp_eq_int_0_uitofp_half(i32 %i) {
141 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half(
142 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
143 ; CHECK-NEXT: ret i1 [[CMP]]
145 %f = uitofp i32 %i to half
146 %b = bitcast half %f to i16
147 %cmp = icmp eq i16 %b, 0
151 define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec(<2 x i32> %i) {
152 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec(
153 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer
154 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
156 %f = uitofp <2 x i32> %i to <2 x half>
157 %b = bitcast <2 x half> %f to <2 x i16>
158 %cmp = icmp eq <2 x i16> %b, <i16 0, i16 0>
162 define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(<3 x i32> %i) {
163 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(
164 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[I:%.*]], zeroinitializer
165 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
167 %f = uitofp <3 x i32> %i to <3 x half>
168 %b = bitcast <3 x half> %f to <3 x i16>
169 %cmp = icmp eq <3 x i16> %b, <i16 0, i16 undef, i16 0>
173 define i1 @i32_cast_cmp_ne_int_0_uitofp_half(i32 %i) {
174 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half(
175 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
176 ; CHECK-NEXT: ret i1 [[CMP]]
178 %f = uitofp i32 %i to half
179 %b = bitcast half %f to i16
180 %cmp = icmp ne i16 %b, 0
184 define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec(<2 x i32> %i) {
185 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec(
186 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer
187 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
189 %f = uitofp <2 x i32> %i to <2 x half>
190 %b = bitcast <2 x half> %f to <2 x i16>
191 %cmp = icmp ne <2 x i16> %b, <i16 0, i16 0>
195 define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(<3 x i32> %i) {
196 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(
197 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[I:%.*]], zeroinitializer
198 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
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 ne <3 x i16> %b, <i16 0, i16 undef, i16 0>