aco: don't byte align global VMEM loads if it might be unsafe

Using the byte align path can be unsafe even when 12 byte loads are
supported.

fossil-db (navi21):
Totals from 185 (0.23% of 79395) affected shaders:
Instrs: 391501 -> 391575 (+0.02%); split: -0.03%, +0.05%
CodeSize: 2147336 -> 2147672 (+0.02%); split: -0.03%, +0.05%
Latency: 3762613 -> 3860941 (+2.61%); split: -0.01%, +2.62%
InvThroughput: 871429 -> 888013 (+1.90%); split: -0.08%, +1.98%
VClause: 9712 -> 10210 (+5.13%)
Copies: 53775 -> 53010 (-1.42%); split: -1.46%, +0.04%
VALU: 254009 -> 252146 (-0.73%)
SALU: 56698 -> 56699 (+0.00%); split: -0.00%, +0.00%
VMEM: 18503 -> 19601 (+5.93%)

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Fixes: 391bf3ea30 ("aco: don't expand smem/mubuf global loads")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31807>
This commit is contained in:
Rhys Perry 2024-09-19 17:57:20 +01:00 committed by Marge Bot
parent dc47ecc9ac
commit b318fe47e9

View file

@ -6901,24 +6901,25 @@ visit_load_global(isel_context* ctx, nir_intrinsic_instr* instr)
info.align_offset = nir_intrinsic_align_offset(instr);
info.sync = get_memory_sync_info(instr, storage_buffer, 0);
/* Don't expand global loads when they use MUBUF or SMEM.
* Global loads don't have the bounds checking that buffer loads have that
/* Global loads don't have the bounds checking that buffer loads have that
* makes this safe.
*/
unsigned align = nir_intrinsic_align(instr);
bool byte_align_for_smem_mubuf =
can_use_byte_align_for_global_load(num_components, component_size, align, false);
bool byte_align_for_vmem = can_use_byte_align_for_global_load(
num_components, component_size, align, ctx->options->gfx_level > GFX6);
bool byte_align_for_smem = can_use_byte_align_for_global_load(
num_components, component_size, align, false);
unsigned access = nir_intrinsic_access(instr) | ACCESS_TYPE_LOAD;
bool glc = access & (ACCESS_VOLATILE | ACCESS_COHERENT);
/* VMEM stores don't update the SMEM cache and it's difficult to prove that
* it's safe to use SMEM */
bool can_use_smem = (access & ACCESS_NON_WRITEABLE) && byte_align_for_smem_mubuf;
bool can_use_smem = (access & ACCESS_NON_WRITEABLE) && byte_align_for_smem;
if (info.dst.type() == RegType::vgpr || (ctx->options->gfx_level < GFX8 && glc) ||
!can_use_smem) {
EmitLoadParameters params = global_load_params;
params.byte_align_loads = ctx->options->gfx_level > GFX6 || byte_align_for_smem_mubuf;
params.byte_align_loads = byte_align_for_vmem;
info.cache = get_cache_flags(ctx, access);
emit_load(ctx, bld, info, params);
} else {