nir: Use deref intrinsics to set writes_memory when gathering info
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 5 May 2020 15:57:12 +0000 (08:57 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 18 May 2020 21:09:17 +0000 (21:09 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4815>

src/compiler/nir/nir_gather_info.c

index f62adb6e1f45ef31ba626ae8d9860a91a204a4dd..09ecc28554b7e566fee8018c5b21f8b5f0278277 100644 (file)
@@ -279,6 +279,20 @@ try_mask_partial_io(nir_shader *shader, nir_variable *var,
    return true;
 }
 
+static void
+update_memory_written_for_deref(nir_shader *shader, nir_deref_instr *deref)
+{
+   switch (deref->mode) {
+   case nir_var_mem_ssbo:
+   case nir_var_mem_global:
+      shader->info.writes_memory = true;
+      break;
+   default:
+      /* Nothing to do. */
+      break;
+   }
+}
+
 static void
 gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
                       void *dead_ctx)
@@ -326,6 +340,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
             }
          }
       }
+      if (instr->intrinsic == nir_intrinsic_store_deref)
+         update_memory_written_for_deref(shader, deref);
       break;
    }
 
@@ -471,6 +487,19 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
       shader->info.writes_memory = true;
       break;
 
+   case nir_intrinsic_deref_atomic_add:
+   case nir_intrinsic_deref_atomic_imin:
+   case nir_intrinsic_deref_atomic_umin:
+   case nir_intrinsic_deref_atomic_imax:
+   case nir_intrinsic_deref_atomic_umax:
+   case nir_intrinsic_deref_atomic_and:
+   case nir_intrinsic_deref_atomic_or:
+   case nir_intrinsic_deref_atomic_xor:
+   case nir_intrinsic_deref_atomic_exchange:
+   case nir_intrinsic_deref_atomic_comp_swap:
+      update_memory_written_for_deref(shader, nir_src_as_deref(instr->src[0]));
+      break;
+
    default:
       break;
    }