[llvm] [RISCV] Be more aggressive about forming floating point constants (PR #68433)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 13:29:53 PDT 2023


================
@@ -2031,10 +2025,10 @@ bool RISCVTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
 
   // Building an integer and then converting requires a fmv at the end of
   // the integer sequence.
-  const int Cost =
-    1 + RISCVMatInt::getIntMatCost(Imm.bitcastToAPInt(), Subtarget.getXLen(),
-                                   Subtarget.getFeatureBits());
-  return Cost <= FPImmCost;
+  int64_t Val = Imm.bitcastToAPInt().getSExtValue();
+  RISCVMatInt::InstSeq Seq =
+      RISCVMatInt::generateInstSeq(Val, Subtarget.getFeatureBits());
+  return Seq.size() + 1 <= Subtarget.getMaxBuildIntsCost();
----------------
topperc wrote:

Should we drop the +1 for Z*inx?

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


More information about the llvm-commits mailing list