llvm.org GIT mirror llvm / 5406c80
[InstSimplify] fold 'fcmp nnan ult X, 0.0' when X is not negative This is the inverted case for the transform added with D53874 / rL345725. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345728 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 11 months ago
2 changed file(s) with 8 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
36193619 if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
36203620 return getTrue(RetTy);
36213621 break;
3622 case FCmpInst::FCMP_ULT:
3623 if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
3624 return getFalse(RetTy);
3625 break;
36223626 case FCmpInst::FCMP_OLT:
3623 // X < 0
36243627 if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
36253628 return getFalse(RetTy);
36263629 break;
289289
290290 define i1 @UIToFP_nnan_is_not_negative(i32 %x) {
291291 ; CHECK-LABEL: @UIToFP_nnan_is_not_negative(
292 ; CHECK-NEXT: [[A:%.*]] = uitofp i32 [[X:%.*]] to float
293 ; CHECK-NEXT: [[R:%.*]] = fcmp nnan ult float [[A]], 0.000000e+00
294 ; CHECK-NEXT: ret i1 [[R]]
292 ; CHECK-NEXT: ret i1 false
295293 ;
296294 %a = uitofp i32 %x to float
297295 %r = fcmp nnan ult float %a, 0.000000e+00
300298
301299 define <2 x i1> @UIToFP_nnan_is_not_negative_vec(<2 x i32> %x) {
302300 ; CHECK-LABEL: @UIToFP_nnan_is_not_negative_vec(
303 ; CHECK-NEXT: [[A:%.*]] = uitofp <2 x i32> [[X:%.*]] to <2 x float>
304 ; CHECK-NEXT: [[R:%.*]] = fcmp nnan ult <2 x float> [[A]], zeroinitializer
305 ; CHECK-NEXT: ret <2 x i1> [[R]]
301 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
306302 ;
307303 %a = uitofp <2 x i32> %x to <2 x float>
308304 %r = fcmp nnan ult <2 x float> %a, zeroinitializer
365361
366362 define i1 @fabs_nnan_is_not_negative(double %x) {
367363 ; CHECK-LABEL: @fabs_nnan_is_not_negative(
368 ; CHECK-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
369 ; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ult double [[FABS]], 0.000000e+00
370 ; CHECK-NEXT: ret i1 [[CMP]]
364 ; CHECK-NEXT: ret i1 false
371365 ;
372366 %fabs = tail call double @llvm.fabs.f64(double %x)
373367 %cmp = fcmp nnan ult double %fabs, 0.0
376370
377371 define <2 x i1> @fabs_nnan_is_not_negative_vec(<2 x double> %x) {
378372 ; CHECK-LABEL: @fabs_nnan_is_not_negative_vec(
379 ; CHECK-NEXT: [[FABS:%.*]] = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
380 ; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan ult <2 x double> [[FABS]], zeroinitializer
381 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
373 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
382374 ;
383375 %fabs = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
384376 %cmp = fcmp nnan ult <2 x double> %fabs, zeroinitializer