[llvm] [SelectionDAG] Fix fcmp fold for new min/max semantics (PR #223655)
Mitch Briles via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 04:46:27 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));
----------------
MitchBriles wrote:
Ok I think preferring PSEUDO_* is a good idea, so I'll add that. The problem is that PSEUDO_* doesn't handle the case where both operands are possibly NaN, so X86 would use its custom FMAXIMUMNUM, which is a bunch of insts. Should I remove it anyway and leave this issue for a follow-up PR?
https://github.com/llvm/llvm-project/pull/223655
More information about the llvm-commits
mailing list