1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
4 define i1 @f16_si_max1(half %f) {
5 ; CHECK-LABEL: @f16_si_max1(
6 ; CHECK-NEXT: [[I:%.*]] = fptosi half [[F:%.*]] to i32
7 ; CHECK-NEXT: [[C:%.*]] = icmp sge i32 [[I]], 65504
8 ; CHECK-NEXT: ret i1 [[C]]
10 %i = fptosi half %f to i32
11 %c = icmp sge i32 %i, 65504
15 define i1 @f16_si_max2(half %f) {
16 ; CHECK-LABEL: @f16_si_max2(
17 ; CHECK-NEXT: ret i1 false
19 %i = fptosi half %f to i32
20 %c = icmp sgt i32 %i, 65504
24 define i1 @f16_si16_max2(half %f) {
25 ; CHECK-LABEL: @f16_si16_max2(
26 ; CHECK-NEXT: [[I:%.*]] = fptosi half [[F:%.*]] to i16
27 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i16 [[I]], -32
28 ; CHECK-NEXT: ret i1 [[C]]
30 %i = fptosi half %f to i16
31 %c = icmp sgt i16 %i, 65504
35 define i1 @f16_si128_max2(half %f) {
36 ; CHECK-LABEL: @f16_si128_max2(
37 ; CHECK-NEXT: ret i1 false
39 %i = fptosi half %f to i128
40 %c = icmp sgt i128 %i, 65504
44 define i1 @f16_si_min1(half %f) {
45 ; CHECK-LABEL: @f16_si_min1(
46 ; CHECK-NEXT: ret i1 true
48 %i = fptosi half %f to i32
49 %c = icmp sge i32 %i, -65504
53 define i1 @f16_si128_min1(half %f) {
54 ; CHECK-LABEL: @f16_si128_min1(
55 ; CHECK-NEXT: ret i1 true
57 %i = fptosi half %f to i128
58 %c = icmp sge i128 %i, -65504
62 define i1 @f16_si16_min1(half %f) {
63 ; CHECK-LABEL: @f16_si16_min1(
64 ; CHECK-NEXT: [[I:%.*]] = fptosi half [[F:%.*]] to i16
65 ; CHECK-NEXT: [[C:%.*]] = icmp sge i16 [[I]], 32
66 ; CHECK-NEXT: ret i1 [[C]]
68 %i = fptosi half %f to i16
69 %c = icmp sge i16 %i, -65504
73 define i1 @f16_si_min2(half %f) {
74 ; CHECK-LABEL: @f16_si_min2(
75 ; CHECK-NEXT: [[I:%.*]] = fptosi half [[F:%.*]] to i32
76 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[I]], -65504
77 ; CHECK-NEXT: ret i1 [[C]]
79 %i = fptosi half %f to i32
80 %c = icmp sgt i32 %i, -65504
84 define i1 @f16_ui_max1(half %f) {
85 ; CHECK-LABEL: @f16_ui_max1(
86 ; CHECK-NEXT: [[I:%.*]] = fptoui half [[F:%.*]] to i32
87 ; CHECK-NEXT: [[C:%.*]] = icmp sge i32 [[I]], 65504
88 ; CHECK-NEXT: ret i1 [[C]]
90 %i = fptoui half %f to i32
91 %c = icmp sge i32 %i, 65504
95 define i1 @f16_ui_max2(half %f) {
96 ; CHECK-LABEL: @f16_ui_max2(
97 ; CHECK-NEXT: ret i1 false
99 %i = fptoui half %f to i32
100 %c = icmp sgt i32 %i, 65504
104 define i1 @f16_ui16_max2(half %f) {
105 ; CHECK-LABEL: @f16_ui16_max2(
106 ; CHECK-NEXT: [[I:%.*]] = fptoui half [[F:%.*]] to i16
107 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i16 [[I]], -32
108 ; CHECK-NEXT: ret i1 [[C]]
110 %i = fptoui half %f to i16
111 %c = icmp sgt i16 %i, 65504
115 define i1 @f16_ui16_max3(half %f) {
116 ; CHECK-LABEL: @f16_ui16_max3(
117 ; CHECK-NEXT: ret i1 true
119 %i = fptoui half %f to i16
120 %c = icmp ule i16 %i, 65504
124 define i1 @f16_ui_min1(half %f) {
125 ; CHECK-LABEL: @f16_ui_min1(
126 ; CHECK-NEXT: ret i1 true
128 %i = fptoui half %f to i32
129 %c = icmp sge i32 %i, 0
133 define i1 @f16_ui16_min1(half %f) {
134 ; CHECK-LABEL: @f16_ui16_min1(
135 ; CHECK-NEXT: [[I:%.*]] = fptoui half [[F:%.*]] to i16
136 ; CHECK-NEXT: [[C:%.*]] = icmp sge i16 [[I]], 0
137 ; CHECK-NEXT: ret i1 [[C]]
139 %i = fptoui half %f to i16
140 %c = icmp sge i16 %i, 0
144 define i1 @f16_ui_min2(half %f) {
145 ; CHECK-LABEL: @f16_ui_min2(
146 ; CHECK-NEXT: [[I:%.*]] = fptoui half [[F:%.*]] to i32
147 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[I]], 0
148 ; CHECK-NEXT: ret i1 [[C]]
150 %i = fptoui half %f to i32
151 %c = icmp sgt i32 %i, 0
157 define <2 x i1> @v2f16_si_max(<2 x half> %f) {
158 ; CHECK-LABEL: @v2f16_si_max(
159 ; CHECK-NEXT: [[I:%.*]] = fptosi <2 x half> [[F:%.*]] to <2 x i32>
160 ; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i32> [[I]], splat (i32 65504)
161 ; CHECK-NEXT: ret <2 x i1> [[C]]
163 %i = fptosi <2 x half> %f to <2 x i32>
164 %c = icmp sge <2 x i32> %i, <i32 65504, i32 65504>
168 define <2 x i1> @v2f16_si_max2(<2 x half> %f) {
169 ; CHECK-LABEL: @v2f16_si_max2(
170 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
172 %i = fptosi <2 x half> %f to <2 x i32>
173 %c = icmp sgt <2 x i32> %i, <i32 65504, i32 65504>
177 define <2 x i1> @v2f16_si16_max2(<2 x half> %f) {
178 ; CHECK-LABEL: @v2f16_si16_max2(
179 ; CHECK-NEXT: [[I:%.*]] = fptosi <2 x half> [[F:%.*]] to <2 x i16>
180 ; CHECK-NEXT: [[C:%.*]] = icmp sgt <2 x i16> [[I]], splat (i16 -32)
181 ; CHECK-NEXT: ret <2 x i1> [[C]]
183 %i = fptosi <2 x half> %f to <2 x i16>
184 %c = icmp sgt <2 x i16> %i, <i16 65504, i16 65504>
188 define <2 x i1> @v2f16_si_min1(<2 x half> %f) {
189 ; CHECK-LABEL: @v2f16_si_min1(
190 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
192 %i = fptosi <2 x half> %f to <2 x i32>
193 %c = icmp sge <2 x i32> %i, <i32 -65504, i32 -65504>
197 define <2 x i1> @v2f16_si16_min1(<2 x half> %f) {
198 ; CHECK-LABEL: @v2f16_si16_min1(
199 ; CHECK-NEXT: [[I:%.*]] = fptosi <2 x half> [[F:%.*]] to <2 x i16>
200 ; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i16> [[I]], splat (i16 32)
201 ; CHECK-NEXT: ret <2 x i1> [[C]]
203 %i = fptosi <2 x half> %f to <2 x i16>
204 %c = icmp sge <2 x i16> %i, <i16 -65504, i16 -65504>
208 define <2 x i1> @v2f16_si_min2(<2 x half> %f) {
209 ; CHECK-LABEL: @v2f16_si_min2(
210 ; CHECK-NEXT: [[I:%.*]] = fptosi <2 x half> [[F:%.*]] to <2 x i32>
211 ; CHECK-NEXT: [[C:%.*]] = icmp sgt <2 x i32> [[I]], splat (i32 -65504)
212 ; CHECK-NEXT: ret <2 x i1> [[C]]
214 %i = fptosi <2 x half> %f to <2 x i32>
215 %c = icmp sgt <2 x i32> %i, <i32 -65504, i32 -65504>
219 define <2 x i1> @v2f16_ui_max1(<2 x half> %f) {
220 ; CHECK-LABEL: @v2f16_ui_max1(
221 ; CHECK-NEXT: [[I:%.*]] = fptoui <2 x half> [[F:%.*]] to <2 x i32>
222 ; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i32> [[I]], splat (i32 65504)
223 ; CHECK-NEXT: ret <2 x i1> [[C]]
225 %i = fptoui <2 x half> %f to <2 x i32>
226 %c = icmp sge <2 x i32> %i, <i32 65504, i32 65504>
230 define <2 x i1> @v2f16_ui_max2(<2 x half> %f) {
231 ; CHECK-LABEL: @v2f16_ui_max2(
232 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
234 %i = fptoui <2 x half> %f to <2 x i32>
235 %c = icmp sgt <2 x i32> %i, <i32 65504, i32 65504>
239 define <2 x i1> @v2f16_ui16_max2(<2 x half> %f) {
240 ; CHECK-LABEL: @v2f16_ui16_max2(
241 ; CHECK-NEXT: [[I:%.*]] = fptoui <2 x half> [[F:%.*]] to <2 x i16>
242 ; CHECK-NEXT: [[C:%.*]] = icmp sgt <2 x i16> [[I]], splat (i16 -32)
243 ; CHECK-NEXT: ret <2 x i1> [[C]]
245 %i = fptoui <2 x half> %f to <2 x i16>
246 %c = icmp sgt <2 x i16> %i, <i16 65504, i16 65504>
250 define <2 x i1> @v2f16_ui16_max3(<2 x half> %f) {
251 ; CHECK-LABEL: @v2f16_ui16_max3(
252 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
254 %i = fptoui <2 x half> %f to <2 x i16>
255 %c = icmp ule <2 x i16> %i, <i16 65504, i16 65504>
259 define <2 x i1> @v2f16_ui_min1(<2 x half> %f) {
260 ; CHECK-LABEL: @v2f16_ui_min1(
261 ; CHECK-NEXT: ret <2 x i1> splat (i1 true)
263 %i = fptoui <2 x half> %f to <2 x i32>
264 %c = icmp sge <2 x i32> %i, <i32 0, i32 0>
268 define <2 x i1> @v2f16_ui16_min1(<2 x half> %f) {
269 ; CHECK-LABEL: @v2f16_ui16_min1(
270 ; CHECK-NEXT: [[I:%.*]] = fptoui <2 x half> [[F:%.*]] to <2 x i16>
271 ; CHECK-NEXT: [[C:%.*]] = icmp sge <2 x i16> [[I]], zeroinitializer
272 ; CHECK-NEXT: ret <2 x i1> [[C]]
274 %i = fptoui <2 x half> %f to <2 x i16>
275 %c = icmp sge <2 x i16> %i, <i16 0, i16 0>
279 define <2 x i1> @v2f16_ui_min2(<2 x half> %f) {
280 ; CHECK-LABEL: @v2f16_ui_min2(
281 ; CHECK-NEXT: [[I:%.*]] = fptoui <2 x half> [[F:%.*]] to <2 x i32>
282 ; CHECK-NEXT: [[C:%.*]] = icmp sgt <2 x i32> [[I]], zeroinitializer
283 ; CHECK-NEXT: ret <2 x i1> [[C]]
285 %i = fptoui <2 x half> %f to <2 x i32>
286 %c = icmp sgt <2 x i32> %i, <i32 0, i32 0>
290 declare i32 @llvm.fptosi.sat.i32.f16(half)
291 declare i32 @llvm.fptoui.sat.i32.f16(half)
292 declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f16(<2 x half>)
293 declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f16(<2 x half>)