radeonsi: fix OpenCL piglit tests fails when using ACO

Now no regression compared with using LLVM.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32781>
This commit is contained in:
Qiang Yu 2024-12-25 09:42:55 +08:00 committed by Marge Bot
parent 21f888a3ed
commit 955ae53efd
2 changed files with 14 additions and 22 deletions

View file

@ -2613,7 +2613,20 @@ static struct nir_shader *si_get_nir_shader(struct si_shader *shader, struct si_
.has_shared2_amd = sel->screen->info.gfx_level >= GFX7,
});
NIR_PASS(progress, nir, nir_opt_shrink_stores, false);
NIR_PASS(progress, nir, ac_nir_lower_global_access);
if (sel->stage == MESA_SHADER_KERNEL) {
NIR_PASS(progress, nir, ac_nir_lower_mem_access_bit_sizes, sel->screen->info.gfx_level, !nir->info.use_aco_amd);
NIR_PASS(progress, nir, ac_nir_lower_global_access);
if (nir->info.bit_sizes_int & (8 | 16)) {
if (sel->screen->info.gfx_level >= GFX8)
nir_divergence_analysis(nir);
NIR_PASS(progress, nir, nir_lower_bit_size, ac_nir_lower_bit_size_callback,
&sel->screen->info.gfx_level);
}
}
/* This must be after vectorization because it causes bindings_different_restrict() to fail. */
NIR_PASS(progress, nir, si_nir_lower_resource, shader, args);

View file

@ -55,26 +55,6 @@ static uint8_t si_vectorize_callback(const nir_instr *instr, const void *data)
}
}
static unsigned si_lower_bit_size_callback(const nir_instr *instr, void *data)
{
if (instr->type != nir_instr_type_alu)
return 0;
nir_alu_instr *alu = nir_instr_as_alu(instr);
switch (alu->op) {
case nir_op_imul_high:
case nir_op_umul_high:
if (alu->def.bit_size < 32)
return 32;
break;
default:
break;
}
return 0;
}
void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first)
{
bool use_aco = sscreen->use_aco || nir->info.use_aco_amd;
@ -120,7 +100,6 @@ void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first)
NIR_PASS(progress, nir, nir_opt_peephole_select, 8, true, true);
/* Needed for algebraic lowering */
NIR_PASS(progress, nir, nir_lower_bit_size, si_lower_bit_size_callback, NULL);
NIR_PASS(progress, nir, nir_opt_algebraic);
NIR_PASS(progress, nir, nir_opt_generate_bfi);
NIR_PASS(progress, nir, nir_opt_constant_folding);