Module: Mesa
Branch: main
Commit: 5eddf60e5604a2e489805e6f73066fbfaee90ca6
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5eddf60e5604a2e489805e6f73066fbfaee90ca6

Author: Ian Romanick <[email protected]>
Date:   Tue May 16 12:21:52 2023 -0700

intel/compiler: Combine control barriers with identical memory semantics

This prevents the second barrier generating a spurious, identical fence
message as the first barrier.

fossil-db stats on Alchemist:

   Totals:
   Instrs: 196513342 -> 196512777 (-0.00%); split: -0.00%, +0.00%
   Cycles: 14271426028 -> 14271404569 (-0.00%); split: -0.00%, +0.00%
   Send messages: 8021892 -> 8021770 (-0.00%)

   Totals from 46 (0.01% of 653252) affected shaders:
   Instrs: 76761 -> 76196 (-0.74%); split: -0.75%, +0.01%
   Cycles: 2027946 -> 2006487 (-1.06%); split: -1.45%, +0.39%
   Send messages: 7589 -> 7467 (-1.61%)

Nothing in shader-db was affected.

Reviewed-by: Kenneth Graunke <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24842>

---

 src/intel/compiler/brw_nir.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index 821d0e90a7b..21a024ea2ad 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -1350,6 +1350,18 @@ bool combine_all_memory_barriers(nir_intrinsic_instr *a,
                                  nir_intrinsic_instr *b,
                                  void *data)
 {
+   /* Combine control barriers with identical memory semantics. This prevents
+    * the second barrier generating a spurious, identical fence message as the
+    * first barrier.
+    */
+   if (nir_intrinsic_memory_modes(a) == nir_intrinsic_memory_modes(b) &&
+       nir_intrinsic_memory_semantics(a) == nir_intrinsic_memory_semantics(b) 
&&
+       nir_intrinsic_memory_scope(a) == nir_intrinsic_memory_scope(b)) {
+      nir_intrinsic_set_execution_scope(a, 
MAX2(nir_intrinsic_execution_scope(a),
+                                                
nir_intrinsic_execution_scope(b)));
+      return true;
+   }
+
    /* Only combine pure memory barriers */
    if ((nir_intrinsic_execution_scope(a) != SCOPE_NONE) ||
        (nir_intrinsic_execution_scope(b) != SCOPE_NONE))

Reply via email to