[llvm] Add FeatureFuseLiterals as SubTargetFeature for Grace and Olympus (PR #160257)

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 29 02:34:15 PDT 2025


================
@@ -12564,6 +12564,17 @@ bool AArch64TargetLowering::isOffsetFoldingLegal(
 
 bool AArch64TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
                                          bool OptForSize) const {
+  // If the constant to be materialized is scalar, it maybe efficient to use
+  // sequence of 'mov + fmov' rather than 'adrp + ldr' on specified CPU's.
+  // However, when materializing vector of constants, there are two things to
+  // note:
+  // 1. Throughput of fmov instruction is very low.
+  // 2. ldr instruction can load multiple constants in one go. Also, it's
+  // throughput is higher as compared to fmov.
+  if (!VT.isVector() && (Subtarget->getCPU() == "neoverse-v2" ||
+                         Subtarget->getCPU() == "olympus"))
+    return true;
----------------
davemgreen wrote:

We would probably want to handle minsize/optsize like below. It would be the Subtarget->hasFuseLiterals that should probably change, being replaced with a new subtarget feature.

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


More information about the llvm-commits mailing list