intel/compiler: run nir_opt_idiv_const before nir_lower_idiv
authorTapani Pälli <tapani.palli@intel.com>
Wed, 19 Oct 2022 08:48:38 +0000 (11:48 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Thu, 20 Oct 2022 12:35:48 +0000 (15:35 +0300)
Integer div lowering can potentially create a lot of code that is
not removed later on. Running const lowering pass first can be used
to eliminate that code.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19157>

src/intel/compiler/brw_nir.c

index d21b3a4..aa47e59 100644 (file)
@@ -1251,6 +1251,8 @@ brw_postprocess_nir(nir_shader *nir, const struct brw_compiler *compiler,
    } while (progress);
 
    if (devinfo->verx10 >= 125) {
+      /* Lower integer division by constants before nir_lower_idiv. */
+      OPT(nir_opt_idiv_const, 32);
       const nir_lower_idiv_options options = {
          .imprecise_32bit_lowering = false,
          .allow_fp16 = false