As the comment notes, the shader results in an INSERT_SUBREG with
"undef" (dead) operand in the Endif block. The register is considered
dead from a liveness analysis perspective. The correct thing to do seems
to be nothing: we keep the undef use of the register, the register
allocator should still be able to take the liveness into account
correctly.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
60,040 ms | x64 debian > MLIR.Examples/standalone::test.toy |
Event Timeline
Could really use a mir test for these sorts of issues
llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.cpp | ||
---|---|---|
535 | Could this see an undef subregister def? Should probably be assert !O.readsReg() (or maybe the loop is buggy to begin with by using use_operands?) | |
llvm/test/CodeGen/AMDGPU/bug-deadlanes.ll | ||
9–11 | Can drop this |
Why I cannot reproduce the assertion? I have tried on latest version and a version several days before.
llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.cpp | ||
---|---|---|
535 |
I guess not in SSA? or could you help point out what it would look like? I think the undef use might also appear in blocks after Endif, so the assertion on part of the cases may be not quite helpful. As we already checked the register is not live in Endif, maybe we can just replace under the check if (UseMI->isPHI() && UseBlock == Endif). But leaving some comment here still useful. |
It turns out my LLVM version was a bit old. In current main it needs -amdgpu-codegenprepare-break-large-phis=false to reproduce. And I'm adding a severely reduced MIR test.
llvm/lib/Target/AMDGPU/SIOptimizeVGPRLiveRange.cpp | ||
---|---|---|
535 | !O.readsReg() seems to make sense, yes. I found the loop a bit surprising as well, but I'm pretty sure it makes sense due to the way it checks for specific basic blocks (that have previously been collected taking liveness into account). |
Could this see an undef subregister def? Should probably be assert !O.readsReg() (or maybe the loop is buggy to begin with by using use_operands?)