ac/llvm: remove the low-optimizing compiler option

Not needed with ACO. It was used for big shaders on old APUs that took
forever to compile.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33046>
This commit is contained in:
Marek Olšák 2024-12-30 19:29:42 -05:00 committed by Marge Bot
parent 08a47fa05c
commit 1f5220b03d
5 changed files with 6 additions and 52 deletions

View file

@ -171,13 +171,6 @@ bool ac_init_llvm_compiler(struct ac_llvm_compiler *compiler, enum radeon_family
if (!compiler->tm)
return false;
if (tm_options & AC_TM_CREATE_LOW_OPT) {
compiler->low_opt_tm =
ac_create_target_machine(family, tm_options, LLVMCodeGenLevelLess, NULL);
if (!compiler->low_opt_tm)
goto fail;
}
compiler->meo =
ac_create_midend_optimizer(compiler->tm, tm_options & AC_TM_CHECK_IR);
if (!compiler->meo)
@ -193,14 +186,11 @@ void ac_destroy_llvm_compiler(struct ac_llvm_compiler *compiler)
{
/* delete the codegen pass managers */
ac_destroy_backend_optimizer(compiler->beo);
ac_destroy_backend_optimizer(compiler->low_opt_beo);
/* delete optimizer pass manager */
if (compiler->meo)
ac_destroy_midend_optimiser(compiler->meo);
if (compiler->low_opt_tm)
LLVMDisposeTargetMachine(compiler->low_opt_tm);
if (compiler->tm)
LLVMDisposeTargetMachine(compiler->tm);
}

View file

@ -31,7 +31,6 @@ enum ac_target_machine_options
{
AC_TM_SUPPORTS_SPILL = 1 << 0,
AC_TM_CHECK_IR = 1 << 1,
AC_TM_CREATE_LOW_OPT = 1 << 2,
};
enum ac_float_mode
@ -47,12 +46,6 @@ struct ac_llvm_compiler {
LLVMTargetMachineRef tm;
struct ac_midend_optimizer *meo;
struct ac_backend_optimizer *beo;
/* Optional compiler for faster compilation with fewer optimizations.
* LLVM modules can be created with "tm" too. There is no difference.
*/
LLVMTargetMachineRef low_opt_tm; /* uses -O1 instead of -O2 */
struct ac_backend_optimizer *low_opt_beo;
};
LLVMTargetRef ac_get_llvm_target(const char *triple);

View file

@ -143,22 +143,11 @@ struct ac_llvm_compiler *si_create_llvm_compiler(struct si_screen *sscreen)
if (!compiler)
return NULL;
/* Only create the less-optimizing version of the compiler on APUs
* predating Ryzen (Raven). */
bool create_low_opt_compiler =
!sscreen->info.has_dedicated_vram && sscreen->info.gfx_level <= GFX8;
enum ac_target_machine_options tm_options =
(sscreen->debug_flags & DBG(CHECK_IR) ? AC_TM_CHECK_IR : 0) |
(create_low_opt_compiler ? AC_TM_CREATE_LOW_OPT : 0);
if (!ac_init_llvm_compiler(compiler, sscreen->info.family, tm_options))
if (!ac_init_llvm_compiler(compiler, sscreen->info.family,
sscreen->debug_flags & DBG(CHECK_IR) ? AC_TM_CHECK_IR : 0))
return NULL;
compiler->beo = ac_create_backend_optimizer(compiler->tm);
if (compiler->low_opt_tm)
compiler->low_opt_beo = ac_create_backend_optimizer(compiler->low_opt_tm);
return compiler;
#else
return NULL;

View file

@ -54,7 +54,7 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context)
bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name, bool less_optimized)
gl_shader_stage stage, const char *name)
{
unsigned count = p_atomic_inc_return(&sscreen->num_compilations);
@ -75,9 +75,6 @@ bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
if (!si_replace_shader(count, binary)) {
struct ac_backend_optimizer *beo = compiler->beo;
if (less_optimized && compiler->low_opt_beo)
beo = compiler->low_opt_beo;
struct si_llvm_diagnostics diag = {debug};
LLVMContextSetDiagnosticHandler(ac->context, si_diagnostic_handler, &diag);
@ -781,20 +778,6 @@ static bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shade
return true;
}
static bool si_should_optimize_less(struct ac_llvm_compiler *compiler,
struct si_shader_selector *sel)
{
if (!compiler->low_opt_beo)
return false;
/* Assume a slow CPU. */
assert(!sel->screen->info.has_dedicated_vram && sel->screen->info.gfx_level <= GFX8);
/* For a crazy dEQP test containing 2597 memory opcodes, mostly
* buffer stores. */
return sel->stage == MESA_SHADER_COMPUTE && sel->info.num_memory_stores > 1000;
}
bool si_llvm_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compiler,
struct si_shader *shader, struct si_shader_args *args,
struct util_debug_callback *debug, struct nir_shader *nir)
@ -858,8 +841,7 @@ bool si_llvm_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *
/* Compile to bytecode. */
if (!si_compile_llvm(sscreen, &shader->binary, &shader->config, compiler, &ctx.ac, debug,
nir->info.stage, si_get_shader_name(shader),
si_should_optimize_less(compiler, shader->selector))) {
nir->info.stage, si_get_shader_name(shader))) {
si_llvm_dispose(&ctx);
fprintf(stderr, "LLVM failed to compile shader\n");
return false;
@ -932,7 +914,7 @@ bool si_llvm_build_shader_part(struct si_screen *sscreen, gl_shader_stage stage,
si_llvm_optimize_module(&ctx);
bool ret = si_compile_llvm(sscreen, &result->binary, &result->config, compiler,
&ctx.ac, debug, ctx.stage, name, false);
&ctx.ac, debug, ctx.stage, name);
si_llvm_dispose(&ctx);
return ret;

View file

@ -51,7 +51,7 @@ static inline struct si_shader_context *si_shader_context_from_abi(struct ac_sha
bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name, bool less_optimized);
gl_shader_stage stage, const char *name);
void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen,
struct ac_llvm_compiler *compiler, unsigned wave_size,
bool exports_color_null, bool exports_mrtz,