[llvm] [RISCV] Use FLI + FNEG to materialize some negative FP constants (PR #70825)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 09:48:54 PDT 2023


================
@@ -3200,8 +3208,12 @@ bool RISCVDAGToDAGISel::selectFPImm(SDValue N, SDValue &Imm) {
 
   MVT VT = CFP->getSimpleValueType(0);
 
-  if (static_cast<const RISCVTargetLowering *>(TLI)->getLegalZfaFPImm(APF,
-                                                                      VT) >= 0)
+  // Even if this FPImm requires an additional FNEG (i.e. the second element of
+  // the returned pair is true) we still prefer FLI + FNEG over immediate
+  // materialization as the latter might generate a longer instruction sequence.
+  if (static_cast<const RISCVTargetLowering *>(TLI)
+          ->getLegalZfaFPImm(APF, VT)
+          .first >= 0)
----------------
mshockwave wrote:

I have no idea why clang-format will prefer formatting like this...

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


More information about the llvm-commits mailing list