From 1e8e785a0754e3edcc3c7bcef6dc50ad7b45c053 Mon Sep 17 00:00:00 2001 From: SoroushIMG Date: Thu, 29 Sep 2022 15:04:21 +0100 Subject: [PATCH] nir: allow to fine tune unrolling for loops with soft fp64 ops Lowered fp64 ops can blow up the loop bodies while still being suitable for unrolling. Allow for using different parameters to unroll loops with soft fp64. Reviewed-by: Mike Blumenkrantz Part-of: --- src/compiler/glsl/gl_nir_linker.c | 4 +++- src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_opt_loop_unroll.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 22dbbf2..ef3d64b 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -111,7 +111,9 @@ gl_nir_opts(nir_shader *nir) NIR_PASS(progress, nir, nir_opt_undef); NIR_PASS(progress, nir, nir_opt_conditional_discard); - if (nir->options->max_unroll_iterations) { + if (nir->options->max_unroll_iterations || + (nir->options->max_unroll_iterations_fp64 && + (nir->options->lower_doubles_options & nir_lower_fp64_full_software))) { NIR_PASS(progress, nir, nir_opt_loop_unroll); } } while (progress); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 06987a8..98dac7e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3622,6 +3622,7 @@ typedef struct nir_shader_compiler_options { unsigned max_unroll_iterations; unsigned max_unroll_iterations_aggressive; + unsigned max_unroll_iterations_fp64; bool lower_uniforms_to_ubo; diff --git a/src/compiler/nir/nir_opt_loop_unroll.c b/src/compiler/nir/nir_opt_loop_unroll.c index 095fd02..43f9816 100644 --- a/src/compiler/nir/nir_opt_loop_unroll.c +++ b/src/compiler/nir/nir_opt_loop_unroll.c @@ -875,6 +875,9 @@ check_unrolling_restrictions(nir_shader *shader, nir_loop *loop) /* Unroll much more aggressively if it can hide load latency. */ if (shader->options->max_unroll_iterations_aggressive && can_pipeline_loads(loop)) max_iter = shader->options->max_unroll_iterations_aggressive; + /* Tune differently if the loop has double ops and soft fp64 is in use */ + else if (shader->options->max_unroll_iterations_fp64 && loop->info->has_soft_fp64) + max_iter = shader->options->max_unroll_iterations_fp64; unsigned trip_count = li->max_trip_count ? li->max_trip_count : li->guessed_trip_count; -- 2.7.4