[llvm] [InlineSpiller][AMDGPU] Skip undef lanes when spilling a partial-def super-register (PR #226689)
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 21:57:04 PDT 2026
qcolombet wrote:
I think this is going in the right direction, but I would rather give the LaneMask directly to the TII hooks that handles the insertion of load and stores than creating a separate API for that. The `-1` index looks hacky BTW.
Regarding the issue we're trying to solve (#225054; for some reason I can't comment there directly), I think there one issue and one opportunity:
1. The issue is that when we rolled out the subregister liveness, we didn't account for it "in memory". What this means is that either we would need to rematerialize all the lanes before we do a store, or we must ensure that we store ONLY the lanes that are live. Doing the latter is the preferred option, but it may be difficult to do it in a generic manner. In a way, I'm surprised it didn't break earlier!
2. In the motivating example of #225054, if I'm not mistaken, we wouldn't actually need the store at all. We're just materializing a split point so we shouldn't have to do the reload->store dance. That's just a missed opportunity.
@xgxanq , I asked my agent to do patches for both, I am sharing them if you want to take a look and productize them.
I eyeballed them and the patch for #2 (split-copy) looked reasonable. The patch for #1 (i.e., the proper fix and a variant of what you're doing (partial-spills)) was going in the right direction but would require more work.
cc: @Muhamed-Husic , @GMNGeoffrey FYI.
PS: I believe that although the hoisting heuristic needs to be fixed, it is not the source of the problem. It just makes it more likely to manifest.
[llvm225054-partial-spills.patch](https://github.com/user-attachments/files/33274809/llvm225054-partial-spills.patch)
[llvm225054-split-copy.patch](https://github.com/user-attachments/files/33274810/llvm225054-split-copy.patch)
https://github.com/llvm/llvm-project/pull/226689
More information about the llvm-commits
mailing list