Skip to content

Commit 3aa2bac

Browse files
committed
[RISCV] Use early return to simplify isFPImmLegal [nfc]
Minor comment and readability change only.
1 parent 48c805b commit 3aa2bac

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,14 +2019,17 @@ bool RISCVTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
20192019
// -0.0 can be created by fmv + fneg.
20202020
return Imm.isZero();
20212021
}
2022-
// Special case: the cost for -0.0 is 1.
2023-
int Cost = Imm.isNegZero()
2024-
? 1
2025-
: RISCVMatInt::getIntMatCost(Imm.bitcastToAPInt(),
2026-
Subtarget.getXLen(),
2027-
Subtarget.getFeatureBits());
2028-
// If the constantpool data is already in cache, only Cost 1 is cheaper.
2029-
return Cost < FPImmCost;
2022+
2023+
// Special case: fmv + fneg
2024+
if (Imm.isNegZero())
2025+
return true;
2026+
2027+
// Building an integer and then converting requires a fmv at the end of
2028+
// the integer sequence.
2029+
const int Cost =
2030+
1 + RISCVMatInt::getIntMatCost(Imm.bitcastToAPInt(), Subtarget.getXLen(),
2031+
Subtarget.getFeatureBits());
2032+
return Cost <= FPImmCost;
20302033
}
20312034

20322035
// TODO: This is very conservative.

0 commit comments

Comments
 (0)