[llvm] expandFMINIMUMNUM_FMAXIMUMNUM: Improve compare between zeros (PR #140193)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 00:45:04 PDT 2025


================
@@ -8704,13 +8705,27 @@ SDValue TargetLowering::expandFMINIMUMNUM_FMAXIMUMNUM(SDNode *Node,
       DAG.getTargetConstant(IsMax ? fcPosZero : fcNegZero, DL, MVT::i32);
   SDValue IsZero = DAG.getSetCC(DL, CCVT, MinMax,
                                 DAG.getConstantFP(0.0, DL, VT), ISD::SETEQ);
-  SDValue LCmp = DAG.getSelect(
-      DL, VT, DAG.getNode(ISD::IS_FPCLASS, DL, CCVT, LHS, TestZero), LHS,
+  unsigned BitSize = VT.getScalarSizeInBits();
+  EVT IntVT = EVT::getIntegerVT(*DAG.getContext(), BitSize);
+  EVT FloatVT = EVT::getFloatingPointVT(32);
+  if (VT.isVector()) {
+    IntVT =
+        EVT::getVectorVT(*DAG.getContext(), IntVT, VT.getVectorElementCount());
----------------
nikic wrote:

You can directly use VT.changeTypeToInteger() to get the corresponding integer type with correct vector handling.

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


More information about the llvm-commits mailing list