[llvm] [AArch64][GlobalISel] Use GPR for illegal fconstants and extend < 32 bit GPR constants to 32 bits (PR #178692)

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 15:02:47 PST 2026


================
@@ -2121,6 +2123,18 @@ bool AArch64InstructionSelector::preISelLower(MachineInstr &I) {
   MachineRegisterInfo &MRI = MF.getRegInfo();
 
   switch (I.getOpcode()) {
+  case TargetOpcode::G_CONSTANT: {
+    Register DefReg = I.getOperand(0).getReg();
+    const LLT DefTy = MRI.getType(DefReg);
+    if (!DefTy.isPointer())
+      return false;
+    const unsigned PtrSize = DefTy.getSizeInBits();
+    if (PtrSize != 32 && PtrSize != 64)
+      return false;
+    // Convert pointer typed constants to integers so TableGen can select.
+    MRI.setType(DefReg, LLT::scalar(PtrSize));
----------------
davemgreen wrote:

Can we get rid of pointers in either legalisation or regbankselect? I think there are more operations that could do with removing pointer types from.

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


More information about the llvm-commits mailing list