[llvm] [SDAG] Fix CSE for ADDRSPACECAST nodes (PR #122912)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 22:19:29 PST 2025


AlexMaclean wrote:

> I'm not sure I understand how stackrestore helps here.

NVPTX has a stackrestore instruction which takes a pointer in the local AS. During operation legalization in ISel we add an addrspacecast node in here to case from generic -> local. This test works by ensuring that the ASC used for the stackrestore does not introduce a new node. This was the simplest way I could think of to get around CSE occurring on the LLVM IR.

> Code change lgtm but a test that doesn't rely on asserts / checking debug output would be better

Yea, I agree it is not ideal, but I've spent some time on it and this is the best I can come up with at the moment. https://github.com/llvm/llvm-project/pull/121710 does rely on this change to ensure load elimination occurs for byval arguments, so once this lands we'll have much better non-debug coverage. 

In the meantime, given that this is a fairly simple and clearly correct fix, is the current method of testing sufficient? 

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


More information about the llvm-commits mailing list