diff options
author | Alexey Bataev <a.bataev@outlook.com> | 2024-07-16 08:14:27 -0400 |
---|---|---|
committer | Alexey Bataev <a.bataev@outlook.com> | 2024-07-16 09:42:08 -0700 |
commit | 8ff233f4f16f4e372cba92ca5175fcd5e1791195 (patch) | |
tree | b175cfbcdd5e0fe658a2ed0e365615024059069b /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 986ceae7c54bcda76edeffa41ff9aa0cd18a3c8e (diff) | |
download | llvm-8ff233f4f16f4e372cba92ca5175fcd5e1791195.zip llvm-8ff233f4f16f4e372cba92ca5175fcd5e1791195.tar.gz llvm-8ff233f4f16f4e372cba92ca5175fcd5e1791195.tar.bz2 |
[SLP]Correctly detect minnum/maxnum patterns for select/cmp operations on floats.
The patch enables detection of minnum/maxnum patterns for float point
instruction, represented as select/cmp. Also, enables better cost
estimation for integer min/max patterns since the compiler starts
to estimate the scalars separately.
Reviewers: nikic, RKSimon
Reviewed By: RKSimon
Pull Request: https://github.com/llvm/llvm-project/pull/98570
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 75e77f8..68e58598 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -8708,10 +8708,7 @@ llvm::canConvertToMinOrMaxIntrinsic(ArrayRef<Value *> VL) { if (all_of(VL, [&SelectPattern, &AllCmpSingleUse](Value *I) { Value *LHS, *RHS; auto CurrentPattern = matchSelectPattern(I, LHS, RHS); - if (!SelectPatternResult::isMinOrMax(CurrentPattern.Flavor) || - CurrentPattern.Flavor == SPF_FMINNUM || - CurrentPattern.Flavor == SPF_FMAXNUM || - !I->getType()->isIntOrIntVectorTy()) + if (!SelectPatternResult::isMinOrMax(CurrentPattern.Flavor)) return false; if (SelectPattern.Flavor != SPF_UNKNOWN && SelectPattern.Flavor != CurrentPattern.Flavor) @@ -8730,6 +8727,10 @@ llvm::canConvertToMinOrMaxIntrinsic(ArrayRef<Value *> VL) { return {Intrinsic::smax, AllCmpSingleUse}; case SPF_UMAX: return {Intrinsic::umax, AllCmpSingleUse}; + case SPF_FMAXNUM: + return {Intrinsic::maxnum, AllCmpSingleUse}; + case SPF_FMINNUM: + return {Intrinsic::minnum, AllCmpSingleUse}; default: llvm_unreachable("unexpected select pattern flavor"); } |