[llvm] [GlobalISel] Implement split extending loads in narrowScalar (PR #190924)
Robin Kastberg via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 12 23:08:55 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)
----------------
RobinKastberg wrote:
I just did my best trying to match the strategy of the if-statements above and e.g. narrowScalar for `G_LOAD` which looks to be using similar strategy.
Are you suggesting I mutate so next round of legalizing will do the reduceLoadStoreWidth?
Because re-implementing reduceLoadStoreWidth here to avoid creating a temporary instruction doesn't seem very good either.
https://github.com/llvm/llvm-project/pull/190924
More information about the llvm-commits
mailing list