[llvm] [SelectionDAG] Fix fcmp fold for new min/max semantics (PR #223655)

Mitch Briles via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 17:51:26 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:

For this PR, I'll keep `isProfitableToCombineMinNumMaxNum`. This mechanism can be replaced in a different patch.

https://github.com/llvm/llvm-project/pull/223655


More information about the llvm-commits mailing list