[llvm] [AArch64][GlobalISel] Use GPR for illegal fconstants and extend < 32 bit GPR constants to 32 bits (PR #178692)
Ryan Cowan via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 19 09:01:07 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));
----------------
HolyMolyCowMan wrote:
It may be possible, but seems to be quite a bit of work. There is precedent for having this type changing in AArch64InstructionSelector.
`G_STORE`, `G_PTR_ADD`, `G_LOAD`, `G_DUP`, `G_INSERT_VECTOR_ELT` all perform a similar operation in `AArch64InstructionSelector::preISelLower`.
https://github.com/llvm/llvm-project/pull/178692
More information about the llvm-commits
mailing list