llvm.org GIT mirror llvm / ea1119a
[InstSimplify] add tests for fcmp and known positive; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345722 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 11 months ago
1 changed file(s) with 106 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
233233 ret i1 %olt
234234 }
235235
236 define i1 @orderedLessZeroUIToFP(i32 %x) {
237 ; CHECK-LABEL: @orderedLessZeroUIToFP(
236 define i1 @UIToFP_is_nan_or_positive_or_zero(i32 %x) {
237 ; CHECK-LABEL: @UIToFP_is_nan_or_positive_or_zero(
238238 ; CHECK-NEXT: ret i1 true
239239 ;
240240 %a = uitofp i32 %x to float
241 %uge = fcmp uge float %a, 0.000000e+00
242 ret i1 %uge
243 }
244
245 define <2 x i1> @orderedLessZeroUIToFP_vec(<2 x i32> %x) {
246 ; CHECK-LABEL: @orderedLessZeroUIToFP_vec(
241 %r = fcmp uge float %a, 0.000000e+00
242 ret i1 %r
243 }
244
245 define <2 x i1> @UIToFP_is_nan_or_positive_or_zero_vec(<2 x i32> %x) {
246 ; CHECK-LABEL: @UIToFP_is_nan_or_positive_or_zero_vec(
247247 ; CHECK-NEXT: ret <2 x i1>
248248 ;
249249 %a = uitofp <2 x i32> %x to <2 x float>
250 %uge = fcmp uge <2 x float> %a, zeroinitializer
251 ret <2 x i1> %uge
252 }
253
254 define i1 @orderedLessZeroUIToFP_nnan(i32 %x) {
255 ; CHECK-LABEL: @orderedLessZeroUIToFP_nnan(
250 %r = fcmp uge <2 x float> %a, zeroinitializer
251 ret <2 x i1> %r
252 }
253
254 define i1 @UIToFP_nnan_is_positive_or_zero(i32 %x) {
255 ; CHECK-LABEL: @UIToFP_nnan_is_positive_or_zero(
256256 ; CHECK-NEXT: [[A:%.*]] = uitofp i32 [[X:%.*]] to float
257 ; CHECK-NEXT: [[UGE:%.*]] = fcmp nnan oge float [[A]], 0.000000e+00
258 ; CHECK-NEXT: ret i1 [[UGE]]
257 ; CHECK-NEXT: [[R:%.*]] = fcmp nnan oge float [[A]], 0.000000e+00
258 ; CHECK-NEXT: ret i1 [[R]]
259259 ;
260260 %a = uitofp i32 %x to float
261 %uge = fcmp nnan oge float %a, 0.000000e+00
262 ret i1 %uge
263 }
264
265 define <2 x i1> @orderedLessZeroUIToFP_nnan_vec(<2 x i32> %x) {
266 ; CHECK-LABEL: @orderedLessZeroUIToFP_nnan_vec(
261 %r = fcmp nnan oge float %a, 0.000000e+00
262 ret i1 %r
263 }
264
265 define <2 x i1> @UIToFP_nnan_is_positive_or_zero_vec(<2 x i32> %x) {
266 ; CHECK-LABEL: @UIToFP_nnan_is_positive_or_zero_vec(
267267 ; CHECK-NEXT: [[A:%.*]] = uitofp <2 x i32> [[X:%.*]] to <2 x float>
268 ; CHECK-NEXT: [[UGE:%.*]] = fcmp nnan oge <2 x float> [[A]], zeroinitializer
269 ; CHECK-NEXT: ret <2 x i1> [[UGE]]
268 ; CHECK-NEXT: [[R:%.*]] = fcmp nnan oge <2 x float> [[A]], zeroinitializer
269 ; CHECK-NEXT: ret <2 x i1> [[R]]
270270 ;
271271 %a = uitofp <2 x i32> %x to <2 x float>
272 %uge = fcmp nnan oge <2 x float> %a, zeroinitializer
273 ret <2 x i1> %uge
272 %r = fcmp nnan oge <2 x float> %a, zeroinitializer
273 ret <2 x i1> %r
274 }
275
276 define i1 @UIToFP_is_not_negative(i32 %x) {
277 ; CHECK-LABEL: @UIToFP_is_not_negative(
278 ; CHECK-NEXT: ret i1 false
279 ;
280 %a = uitofp i32 %x to float
281 %r = fcmp olt float %a, 0.000000e+00
282 ret i1 %r
283 }
284
285 define <2 x i1> @UIToFP_is_not_negative_vec(<2 x i32> %x) {
286 ; CHECK-LABEL: @UIToFP_is_not_negative_vec(
287 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
288 ;
289 %a = uitofp <2 x i32> %x to <2 x float>
290 %r = fcmp olt <2 x float> %a, zeroinitializer
291 ret <2 x i1> %r
292 }
293
294 define i1 @UIToFP_nnan_is_not_negative(i32 %x) {
295 ; CHECK-LABEL: @UIToFP_nnan_is_not_negative(
296 ; CHECK-NEXT: [[A:%.*]] = uitofp i32 [[X:%.*]] to float
297 ; CHECK-NEXT: [[R:%.*]] = fcmp nnan ult float [[A]], 0.000000e+00
298 ; CHECK-NEXT: ret i1 [[R]]
299 ;
300 %a = uitofp i32 %x to float
301 %r = fcmp nnan ult float %a, 0.000000e+00
302 ret i1 %r
303 }
304
305 define <2 x i1> @UIToFP_nnan_is_not_negative_vec(<2 x i32> %x) {
306 ; CHECK-LABEL: @UIToFP_nnan_is_not_negative_vec(
307 ; CHECK-NEXT: [[A:%.*]] = uitofp <2 x i32> [[X:%.*]] to <2 x float>
308 ; CHECK-NEXT: [[R:%.*]] = fcmp nnan ult <2 x float> [[A]], zeroinitializer
309 ; CHECK-NEXT: ret <2 x i1> [[R]]
310 ;
311 %a = uitofp <2 x i32> %x to <2 x float>
312 %r = fcmp nnan ult <2 x float> %a, zeroinitializer
313 ret <2 x i1> %r
274314 }
275315
276316 define i1 @fabs_is_nan_or_positive_or_zero(double %x) {
310350 ;
311351 %fabs = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
312352 %cmp = fcmp nnan oge <2 x double> %fabs, zeroinitializer
353 ret <2 x i1> %cmp
354 }
355
356 define i1 @fabs_is_not_negative(double %x) {
357 ; CHECK-LABEL: @fabs_is_not_negative(
358 ; CHECK-NEXT: ret i1 false
359 ;
360 %fabs = tail call double @llvm.fabs.f64(double %x)
361 %cmp = fcmp olt double %fabs, 0.0
362 ret i1 %cmp
363 }
364
365 define <2 x i1> @fabs_is_not_negative_vec(<2 x double> %x) {
366 ; CHECK-LABEL: @fabs_is_not_negative_vec(
367 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
368 ;
369 %fabs = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
370 %cmp = fcmp olt <2 x double> %fabs, zeroinitializer
371 ret <2 x i1> %cmp
372 }
373
374 define i1 @fabs_nnan_is_not_negative(double %x) {
375 ; CHECK-LABEL: @fabs_nnan_is_not_negative(
376 ; CHECK-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
377 ; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ult double [[FABS]], 0.000000e+00
378 ; CHECK-NEXT: ret i1 [[CMP]]
379 ;
380 %fabs = tail call double @llvm.fabs.f64(double %x)
381 %cmp = fcmp nnan ult double %fabs, 0.0
382 ret i1 %cmp
383 }
384
385 define <2 x i1> @fabs_nnan_is_not_negative_vec(<2 x double> %x) {
386 ; CHECK-LABEL: @fabs_nnan_is_not_negative_vec(
387 ; CHECK-NEXT: [[FABS:%.*]] = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
388 ; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ult <2 x double> [[FABS]], zeroinitializer
389 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
390 ;
391 %fabs = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
392 %cmp = fcmp nnan ult <2 x double> %fabs, zeroinitializer
313393 ret <2 x i1> %cmp
314394 }
315395