[llvm-branch-commits] [llvm] [AMDGPU] Price buffer fat pointer memory operations (PR #238842)

Jay Foad via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 9 01:54:11 PST 2026


jayfoad wrote:

Comment from Claude below. It does seem odd that isel would split wide accesses that SILoadStoreOptimizer is just going to merge back together. Cc @krzysz00 @piotrAMD 

- **Medium** (mostly an observation to raise, not necessarily a change to this PR): in strict mode the TTI prices the lowering's per-dword split for unknown offsets. SILoadStoreOptimizer then re-merges the split dwords whenever they share a vaddr. So for the common `rsrc + runtime offset` pattern, the cost is 4x what is emitted.
  - Relative SLP decisions are mostly unaffected, because scalar dword loads are also re-merged.
  - But it is a regression in absolute accuracy against base for that pattern, and the PR claims "the width comes from buffer fat pointer lowering".
  - More importantly, the re-merge looks like it defeats the purpose of the strict-OOB split (the wrap-around case `NoWrapFromMax` exists for). Worth asking krzysz00 whether `SILoadStoreOptimizer` should refuse to merge buffer accesses that
  - Example: `<4 x i32> align 4`. TTI says 4 (was 1). Lowering does emit 4x `raw.ptr.buffer.load.i32` at `%off+0/4/8/12` (checked with `-passes=amdgpu-lower-buffer-fat-pointers`). MIR before `si-load-store-opt` has 4x `BUFFER_LOAD_DWORD_OFFEN` with the same vaddr and imm 0/4/8/12.
  - But **SILoadStoreOptimizer re-merges them into one `buffer_load_dwordx4`** (same for stores: `buffer_store_dwordx4`). Likewise `<8 x i32>` -> 2x dwordx4, `<16 x i32>` -> 4x dwordx4. With a constant `-8` offset they partially re-merge (dword, dword, dwordx2).
  - With an opaque p7 argument the split survives (4x `buffer_load_dword`), and the TTI is exact there.
  - So the IR-level split the TTI models is often undone in the final ISA.

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


More information about the llvm-branch-commits mailing list