[llvm] [AMDGPU] Add function attribute to disable TBUFFER combine (PR #156454)

Piotr Sobczak via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 03:13:43 PDT 2025


piotrAMD wrote:

Agreed that we should be correct by default, so tbuffer merges should not happen unless a certain function attribute is set that allows it. 

The use case is slightly different than relaxed-buffer-oob-mode though. In this case it is due to a recent Vulkan spec hardening extension https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_maintenance9.html that says: "Add a property to indicate the implementation will return (0,0,0,0) or (0,0,0,1) to vertex shaders that read unassigned attributes.".
We can't merge tbuffers in this case, because tbuffers are not checked by component, so we can't selectively return the oob value.

The driver property that drives this is different than the property that drives relaxed-buffer-oob-mode, so there should be two different mechanisms to avoid code pessimization.

Also note, the middle-end merging never happens for tbuffers, because they are intrinsincs all the way - at no point are they regular llvm loads.

Having said that, I agree si-load-store-optimizer should also be updated to check for relaxed-buffer-oob-mode to disallow buffer merging, but this is a separate change.

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


More information about the llvm-commits mailing list