Mesa (master): nir/large_constants: pass after lowering copy_deref

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Sep 16 11:47:21 UTC 2019


Module: Mesa
Branch: master
Commit: 2bfcf043456411a6037404d9afae9760964c9b48
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2bfcf043456411a6037404d9afae9760964c9b48

Author: Sergii Romantsov <sergii.romantsov at globallogic.com>
Date:   Thu Aug 29 10:58:38 2019 +0300

nir/large_constants: pass after lowering copy_deref

v2: by J.Ekstrand suggestion moved lowering of large
    constants after lowering of copy_deref is done.

CC: Jason Ekstrand <jason at jlekstrand.net>
CC: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111450
Signed-off-by: Sergii Romantsov <sergii.romantsov at globallogic.com>

---

 src/compiler/nir/nir_opt_large_constants.c | 27 ++-------------------------
 src/intel/compiler/brw_nir.c               | 14 +++++++-------
 2 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/src/compiler/nir/nir_opt_large_constants.c b/src/compiler/nir/nir_opt_large_constants.c
index 8fd1f0d2e99..bc67496836e 100644
--- a/src/compiler/nir/nir_opt_large_constants.c
+++ b/src/compiler/nir/nir_opt_large_constants.c
@@ -222,13 +222,7 @@ nir_opt_large_constants(nir_shader *shader,
             break;
 
          case nir_intrinsic_copy_deref:
-            /* We always assume the src and therefore the dst are not
-             * constants here. Copy and constant propagation passes should
-             * have taken care of this in most cases anyway.
-             */
-            dst_deref = nir_src_as_deref(intrin->src[0]);
-            src_deref = nir_src_as_deref(intrin->src[1]);
-            src_is_const = false;
+            assert(!"Lowering of copy_deref with large constants is prohibited");
             break;
 
          default:
@@ -366,24 +360,7 @@ nir_opt_large_constants(nir_shader *shader,
             }
             break;
          }
-
-         case nir_intrinsic_copy_deref: {
-            nir_deref_instr *deref = nir_src_as_deref(intrin->src[1]);
-            if (deref->mode != nir_var_function_temp)
-               continue;
-
-            nir_variable *var = nir_deref_instr_get_variable(deref);
-            struct var_info *info = &var_infos[var->data.index];
-            if (info->is_constant) {
-               b.cursor = nir_after_instr(&intrin->instr);
-               nir_ssa_def *val = build_constant_load(&b, deref, size_align);
-               nir_store_deref(&b, nir_src_as_deref(intrin->src[0]), val, ~0);
-               nir_instr_remove(&intrin->instr);
-               nir_deref_instr_remove_if_unused(deref);
-            }
-            break;
-         }
-
+         case nir_intrinsic_copy_deref:
          default:
             continue;
          }
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index c710fe46e5d..ed6bcff7009 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -690,13 +690,6 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir,
    OPT(nir_lower_doubles, softfp64, nir->options->lower_doubles_options);
    OPT(nir_lower_int64, nir->options->lower_int64_options);
 
-   /* This needs to be run after the first optimization pass but before we
-    * lower indirect derefs away
-    */
-   if (compiler->supports_shader_constants) {
-      OPT(nir_opt_large_constants, NULL, 32);
-   }
-
    OPT(nir_lower_bit_size, lower_bit_size_callback, (void *)compiler);
 
    if (is_scalar) {
@@ -706,6 +699,13 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir,
    /* Lower a bunch of stuff */
    OPT(nir_lower_var_copies);
 
+   /* This needs to be run after the first optimization pass but before we
+    * lower indirect derefs away
+    */
+   if (compiler->supports_shader_constants) {
+      OPT(nir_opt_large_constants, NULL, 32);
+   }
+
    OPT(nir_lower_system_values);
 
    const nir_lower_subgroups_options subgroups_options = {




More information about the mesa-commit mailing list