[llvm] [RISCV][ISelLowering] Use Zicond for FP selects on Zfinx/Zdinx (PR #169299)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 25 10:37:04 PST 2025
================
@@ -9555,6 +9555,54 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
if (SDValue V = lowerSelectToBinOp(Op.getNode(), DAG, Subtarget))
return V;
+ // When there is no cost for GPR <-> FGPR, we can use zicond select for
+ // floating value when CondV is int type
+ bool FPinGPR = Subtarget.hasStdExtZfinx();
+
+ // We can handle FGPR without spliting into hi/lo parts
+ bool FitsInGPR = TypeSize::isKnownLE(VT.getSizeInBits(),
+ Subtarget.getXLenVT().getSizeInBits());
+
+ bool UseZicondForFPSel = Subtarget.hasStdExtZicond() && FPinGPR &&
+ VT.isFloatingPoint() && FitsInGPR;
+
+ if (UseZicondForFPSel) {
+ MVT XLenIntVT = Subtarget.getXLenVT();
+
+ auto CastToInt = [&](SDValue V) -> SDValue {
+ // Treat +0.0 as integer 0 to enable single 'czero' instruction
+ // generation.
+ if (auto *CFP = dyn_cast<ConstantFPSDNode>(V)) {
+ if (CFP->isZero() && !CFP->isNegative())
----------------
topperc wrote:
Oh that only exists in APFloat.
https://github.com/llvm/llvm-project/pull/169299
More information about the llvm-commits
mailing list