nir: Remove deref chain support from lower_system_values
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 27 Mar 2018 16:08:31 +0000 (09:08 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 23 Jun 2018 03:54:00 +0000 (20:54 -0700)
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/nir/nir_lower_system_values.c

index 0f27d039d08b37a94c5bf4cc8294951c5ebee4d7..d2abc656fa1e8b7c4e46b2e9b71fadf1d4dd2e0e 100644 (file)
@@ -37,21 +37,17 @@ convert_block(nir_block *block, nir_builder *b)
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
-      nir_intrinsic_instr *load_var = nir_instr_as_intrinsic(instr);
-
-      nir_variable *var;
-      if (load_var->intrinsic == nir_intrinsic_load_var) {
-         var = load_var->variables[0]->var;
-      } else if (load_var->intrinsic == nir_intrinsic_load_deref) {
-         var = nir_deref_instr_get_variable(nir_src_as_deref(load_var->src[0]));
-      } else {
-         continue; /* Not a load instruction */
-      }
+      nir_intrinsic_instr *load_deref = nir_instr_as_intrinsic(instr);
+      if (load_deref->intrinsic != nir_intrinsic_load_deref)
+         continue;
+
+      nir_variable *var =
+         nir_deref_instr_get_variable(nir_src_as_deref(load_deref->src[0]));
 
       if (var->data.mode != nir_var_system_value)
          continue;
 
-      b->cursor = nir_after_instr(&load_var->instr);
+      b->cursor = nir_after_instr(&load_deref->instr);
 
       nir_ssa_def *sysval = NULL;
       switch (var->data.location) {
@@ -178,8 +174,8 @@ convert_block(nir_block *block, nir_builder *b)
          sysval = nir_load_system_value(b, sysval_op, 0);
       }
 
-      nir_ssa_def_rewrite_uses(&load_var->dest.ssa, nir_src_for_ssa(sysval));
-      nir_instr_remove(&load_var->instr);
+      nir_ssa_def_rewrite_uses(&load_deref->dest.ssa, nir_src_for_ssa(sysval));
+      nir_instr_remove(&load_deref->instr);
 
       progress = true;
    }
@@ -208,6 +204,8 @@ nir_lower_system_values(nir_shader *shader)
 {
    bool progress = false;
 
+   nir_assert_unlowered_derefs(shader, nir_lower_load_store_derefs);
+
    nir_foreach_function(function, shader) {
       if (function->impl)
          progress = convert_impl(function->impl) || progress;