[llvm] expandFMINIMUMNUM_FMAXIMUMNUM: Improve compare between zeros (PR #140193)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 20:41:31 PST 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());
+ FloatVT = EVT::getVectorVT(*DAG.getContext(), FloatVT,
+ VT.getVectorElementCount());
+ }
+ SDValue LHSTrunc = LHS;
+ if (!isOperationLegal(ISD::BITCAST, IntVT) &&
+ !isOperationLegal(ISD::IS_FPCLASS, VT)) {
+ LHSTrunc = DAG.getNode(ISD::FP_ROUND, DL, FloatVT, LHS,
+ DAG.getIntPtrConstant(0, DL, /*isTarget=*/true));
----------------
wzssyqa wrote:
Arm32 doesn't use `expandFMINIMUMNUM_FMAXIMUMNUM`. So I add testcase for AARCH64 and x86.
https://github.com/llvm/llvm-project/pull/140193
More information about the llvm-commits
mailing list