[llvm] [SelectionDAG] Fix fcmp fold for new min/max semantics (PR #223655)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 04:18:00 PDT 2026
================
@@ -7040,12 +7036,20 @@ static SDValue foldAndOrOfSETCC(SDNode *LogicOp, SelectionDAG &DAG) {
TLI.isOperationLegal(ISD::FMINNUM_IEEE, OpVT);
bool isFMAXNUMFMINNUM = TLI.isOperationLegalOrCustom(ISD::FMAXNUM, OpVT) &&
TLI.isOperationLegalOrCustom(ISD::FMINNUM, OpVT);
+ // A custom FMINIMUMNUM/FMAXIMUMNUM may be more expensive than the compares,
+ // so only use one if the target considers forming it profitable.
+ bool isFMAXIMUMNUMFMINIMUMNUM =
+ (TLI.isOperationLegal(ISD::FMAXIMUMNUM, OpVT) &&
+ TLI.isOperationLegal(ISD::FMINIMUMNUM, OpVT)) ||
+ (TLI.isOperationLegalOrCustom(ISD::FMAXIMUMNUM, OpVT) &&
+ TLI.isOperationLegalOrCustom(ISD::FMINIMUMNUM, OpVT) &&
+ TLI.isProfitableToCombineMinNumMaxNum(OpVT));
----------------
arsenm wrote:
I am disappointed that isProfitableToCombineMinNumMaxNum exists, and I think it should be removed. Given the X86 comment in it's implementation, and that PSEUDO_FMIN/FMAX now exist, I think we would be better off removing it and adding the PSEUDO_* cases to these combines as preferred if available
https://github.com/llvm/llvm-project/pull/223655
More information about the llvm-commits
mailing list