[llvm] [GlobalISel] Implement split extending loads in narrowScalar (PR #190924)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 10 12:07:24 PDT 2026
================
@@ -1699,8 +1699,12 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
} else if (MemSize < NarrowSize) {
MIRBuilder.buildLoadInstr(LoadMI.getOpcode(), TmpReg, PtrReg, MMO);
} else if (MemSize > NarrowSize) {
- // FIXME: Need to split the load.
- return UnableToLegalize;
+ TmpReg = MRI.createGenericVirtualRegister(MMO.getMemoryType());
+
+ MachineInstr *ExactLoad = MIRBuilder.buildLoad(TmpReg, PtrReg, MMO);
+ GLoadStore &LdSt = cast<GLoadStore>(*ExactLoad);
+ if (reduceLoadStoreWidth(LdSt, 0, NarrowTy) != Legalized)
----------------
arsenm wrote:
This shouldn't create a new temporary instruction just to re-legalize it. The APIs here could use cleanup, but without changing much you can mutate the return type in place, I guess
https://github.com/llvm/llvm-project/pull/190924
More information about the llvm-commits
mailing list