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

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 13:38:23 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();
----------------
preames wrote:

Yep, but let's do that in a separate commit to keep diffs understandable. 

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


More information about the llvm-commits mailing list