[llvm] [AArch64][GlobalISel] Remove fconstant_to_constant, moving it to reg-bank-select. (PR #194778)

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 02:04:15 PDT 2026


================
@@ -379,6 +380,13 @@ static bool preferGPRForFPImm(const MachineInstr &MI,
   const APFloat Imm = MI.getOperand(1).getFPImm()->getValueAPF();
   const APInt ImmBits = Imm.bitcastToAPInt();
 
+  // If all the uses are stores use a gpr constant
+  if (all_of(MRI.use_nodbg_instructions(Dst), [&](const MachineInstr &UseMI) {
+        return UseMI.getOpcode() == TargetOpcode::G_STORE &&
+               UseMI.getOperand(0).getReg() == Dst;
+      }))
+    return true;
+
----------------
davemgreen wrote:

Yep - I had originally though the same thing and had added an extra check for it. I don't have the code any more but after trying it, all immediates that can be represented by a fmov can be apparently be materialized by a single mov on the gpr side. The fmov only has 8bits of internal representation and only ever sets the top 16bits of the value.

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


More information about the llvm-commits mailing list