[llvm] [RISCV] Enable rematerialization for scalar loads (PR #166774)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 6 11:32:55 PST 2025


https://github.com/preames commented:

Summarizing some offline conversation with Craig.  We happened to chat about this idea yesterday.  

Cases this might kick in:
- Arguments - will be frame indices during regalloc, and rewritten afterwards, so no concerns for e.g. dynamic alloc offset calculations.
- Globals, particularly pc-relative.  Remating the LD without the whole sequence might break the assumption of the AUIPC offset?

Craig, can you expand on the later just a bit?  As long as we don't move the AUIPC, isn't the low offset fixed?  It's the pc relative offset from the AUIPC to the global, not from the LD to the global isn't it?

Luke, could you add a test case which does a constant global load before the asm block, and then a use after?  We should be able to remat that, but it's the case we were a bit unclear on so having specific testing is good.  

https://github.com/llvm/llvm-project/pull/166774


More information about the llvm-commits mailing list