From d3adef316414bf94b61248c1a631fffcf21a9e52 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 24 Apr 2025 17:05:44 -0400 Subject: [PATCH] agx: defer nir_opt_idiv_const noticed in GS work. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 5a9d6d68c0a..495bbaecc56 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -3773,16 +3773,6 @@ agx_preprocess_nir(nir_shader *nir) /* Clean up deref gunk after lowering I/O */ NIR_PASS(_, nir, nir_opt_dce); - /* Runs before we lower away idiv, to work at all. But runs after lowering - * textures, since the cube map array lowering generates division by 6. - */ - NIR_PASS(_, nir, nir_opt_idiv_const, 16); - - nir_lower_idiv_options idiv_options = { - .allow_fp16 = true, - }; - - NIR_PASS(_, nir, nir_lower_idiv, &idiv_options); NIR_PASS(_, nir, nir_lower_frexp); NIR_PASS(_, nir, nir_lower_alu); NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL); @@ -3802,6 +3792,16 @@ agx_preprocess_nir(nir_shader *nir) */ agx_optimize_loop_nir(nir); + /* Lower idiv after an optimization loop so we can constant fold more before + * nir_opt_idiv_const. + */ + NIR_PASS(_, nir, nir_opt_idiv_const, 16); + + nir_lower_idiv_options idiv_options = { + .allow_fp16 = true, + }; + + NIR_PASS(_, nir, nir_lower_idiv, &idiv_options); NIR_PASS(_, nir, nir_opt_deref); NIR_PASS(_, nir, nir_lower_vars_to_ssa);