nir/divergence: improve DA of shuffle
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 12 Nov 2019 15:29:45 +0000 (15:29 +0000)
committerRhys Perry <pendingchaos02@gmail.com>
Tue, 12 Nov 2019 17:21:38 +0000 (17:21 +0000)
If the data is uniform, then it's really a uniform copy. If the index is
uniform, then it's really a read_invocation.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
src/compiler/nir/nir_divergence_analysis.c

index 301d7a4820b09d9a6efad17f62460f294c22f94e..9b8f9cb6349f185e2334d48ef18f8b933d1f67ba 100644 (file)
@@ -200,7 +200,6 @@ visit_intrinsic(bool *divergent, nir_intrinsic_instr *instr,
    case nir_intrinsic_ballot_find_lsb:
    case nir_intrinsic_ballot_find_msb:
    case nir_intrinsic_ballot_bit_count_reduce:
-   case nir_intrinsic_shuffle:
    case nir_intrinsic_shuffle_xor:
    case nir_intrinsic_shuffle_up:
    case nir_intrinsic_shuffle_down:
@@ -247,6 +246,11 @@ visit_intrinsic(bool *divergent, nir_intrinsic_instr *instr,
       break;
    }
 
+   case nir_intrinsic_shuffle:
+      is_divergent = divergent[instr->src[0].ssa->index] &&
+                     divergent[instr->src[1].ssa->index];
+      break;
+
    /* Intrinsics which are always divergent */
    case nir_intrinsic_load_color0:
    case nir_intrinsic_load_color1: