[llvm] [AMDGPU] Support merging 16-bit and 8-bit TBUFFER load/store instruction (PR #145078)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 06:46:24 PDT 2025
================
@@ -1060,13 +1068,46 @@ bool SILoadStoreOptimizer::offsetsCanBeCombined(CombineInfo &CI,
Info0->NumFormat != Info1->NumFormat)
return false;
- // TODO: Should be possible to support more formats, but if format loads
- // are not dword-aligned, the merged load might not be valid.
- if (Info0->BitsPerComp != 32)
+ // For 8-bit or 16-bit formats there is no 3-component variant.
+ // If NumCombinedComponents is 3, try the 4-component format and use XYZ.
+ // Example:
+ // tbuffer_load_format_x + tbuffer_load_format_x + tbuffer_load_format_x
+ // ==> tbuffer_load_format_xyz with format:[BUF_FMT_16_16_16_16_SNORM]
+ unsigned NumCombinedComponents = CI.Width + Paired.Width;
+ unsigned CombinedBufferFormat =
----------------
jayfoad wrote:
I'd prefer that you implement this in _exactly_ the same way that you do in `mergeTBufferLoadPair` and `mergeTBufferStorePair`:
```
if (NumCombinedComponents == 3 && CI.EltSize <= 2)
NumCombinedComponents = 4;
```
https://github.com/llvm/llvm-project/pull/145078
More information about the llvm-commits
mailing list