diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 8eacc0d93b6..2fe34c49175 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 73429000f04..1db50f87ec7 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -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);