[llvm] [RISCV] Use proper LLA operand for constant from load (PR #142292)

Carl Nettelblad via llvm-commits llvm-commits at lists.llvm.org
Sat May 31 15:31:48 PDT 2025


cnettel wrote:

> Do you have a test case to illustrate the bug you're trying to fix?

I apologize for not providing one straight away. I only get the behavior when LLA was used for constant pools in a larger project (involving LLVMCPU lowering with IREE), with a quite complex build environment. In fact, I stumbled on this from the very fact that for small test programs, I saw much better optimization than on the full thing, despite the optimization flags being identical.

This one-line fix brings those two cases in line with each other, but it is not a minimal reproduction. I'm not familiar enough with the various memory, linkage, and relocations models of RISC-V to know when LLA will be triggered for constant pools. In any such scenario where a late stage KnownBits optimization is possible, the behavior should be triggered.

The existing code is buggy in the sense that the return value from GetSupportedConstantPool will always return nullptr in the line affected by the commit. As things stand, Ptr is checked to be a ConstantPoolSDNode, but we only enter that block if Ptr has been established to be a RISCVISD::LLA opcode.



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


More information about the llvm-commits mailing list