AMDGPU backend: range is set incorrectly for mbcnt instructions
According to the GCN / RDNA ISA documentation, the v_mbcnt_lo and v_mbcnt_hi instructions can have a source which is added to the result. The LLVM AMDGPU backend disregards this and always sets the range of these instructions as if their upper bound was the wave size, however this is incorrect when the addition is used because it can then exceed this range.
The problematic line of code is this: https://github.com/llvm/llvm-project/blob/25af3af/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp#L4601
This causes false assumptions when the instruction is used with arbitrary addition, resulting in buggy code being compiled.
@llvm/issue-subscribers-backend-amdgpu
Caused by https://reviews.llvm.org/D39951
I took a look at this - see https://reviews.llvm.org/D131478
Fixed in https://reviews.llvm.org/D131478
Can you say which version of LLVM will have this fix?
(Sorry for delayed response - been on vacation)
I'm trying to get a backport to the llvm 15 release.
If not for llvm 15, then it'll be in the next release.
Thanks. Please let me know when you know for sure. (As a workaround we emit an extra add instruction now, but I'd like to remove that workaround for the first LLVM version which doesn't need it.)
The change should be in 15.0.1 See https://github.com/llvm/llvm-project-release-prs/pull/124 and https://github.com/llvm/llvm-project/issues/57295
Ouch. Sad to see it didn't make it into 15.0.0 :(
Thanks for the fix and thanks for letting me know it will be usable in 15.0.1 at least.