[llvm] SelectionDAG/expandFMINIMUMNUM_FMAXIMUMNUM: FCANONICALIZE is needed only for sNaN (PR #108180)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 02:59:19 PDT 2024


https://github.com/wzssyqa created https://github.com/llvm/llvm-project/pull/108180

If we are sure that it is not sNaN, even it may be qNaN, we can use it directly.

>From 76724367e7e21db56b8ebf4022a269121f825adc Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at debian.org>
Date: Wed, 11 Sep 2024 17:56:00 +0800
Subject: [PATCH] SelectionDAG/expandFMINIMUMNUM_FMAXIMUMNUM: FCANONICALIZE is
 needed only for sNaN

If we are sure that it is not sNaN, even it may be qNaN, we can use
it directly.
---
 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 03010c1df00145..042661af1c8f96 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -8614,8 +8614,8 @@ SDValue TargetLowering::expandFMINIMUMNUM_FMAXIMUMNUM(SDNode *Node,
   SDValue MinMax =
       DAG.getSelectCC(DL, LHS, RHS, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);
   // If MinMax is NaN, let's quiet it.
-  if (!Flags.hasNoNaNs() && !DAG.isKnownNeverNaN(LHS) &&
-      !DAG.isKnownNeverNaN(RHS)) {
+  if (!Flags.hasNoNaNs() && !DAG.isKnownNeverSNaN(LHS) &&
+      !DAG.isKnownNeverSNaN(RHS)) {
     MinMax = DAG.getNode(ISD::FCANONICALIZE, DL, VT, MinMax, Flags);
   }
 



More information about the llvm-commits mailing list