nir_opt_remove_phis breaks divergence analysis
Below is the differences before and after running nir_opt_remove_phis
on ssbo-atomicCompSwap-int.shader_test. Both %38
and %39
are correctly marked divergent. However, %13
and %14
are convergent. Replacing %39
with %13
or %38
with %14
is not correct.
I'm not sure what the right fix is. Is it just improper to call nir_opt_remove_phis
while expecting divergence analysis to remain correct? Should nir_opt_remove_phis
detect this case and not remove these phis?
--- /tmp/before.txt 2024-03-01 11:33:09.446941363 -0800
+++ /tmp/after.txt 2024-03-01 11:33:22.493942239 -0800
@@ -1,4 +1,4 @@
-intel_nir_blockify_uniform_loads
+nir_opt_remove_phis
shader: MESA_SHADER_FRAGMENT
source_sha1: {0x87c8e9d0, 0x23efeaee, 0x089da05c, 0x8b8ba28f, 0x86622ae1}
name: GLSL3
@@ -69,17 +69,15 @@
block b8: // preds: b7, succs: b2
}
block b9: // preds: b3 b6
- div 32 %39 = phi b3: %13, b6: %13
- div 32 %38 = phi b3: %14, b6: %14
div 1 %19 = phi b3: %5 (true), b6: %4 (false)
div 1 %20 = inot %19
// succs: b10 b14
if %20 {
block b10: // preds: b9
con 32 %21 = load_const (0x00000002)
- div 32 %22 = ushr %39, %21 (0x2)
+ div 32 %22 = ushr %13, %21 (0x2)
div 32 %23 = ishl %12 (0x1), %22
- div 32 %24 = ishl %38, %21 (0x2)
+ div 32 %24 = ishl %14, %21 (0x2)
div 32 %25 = @ssbo_atomic (%21 (0x2), %24, %23) (access=none, atomic_op=ior)
div 32 %26 = iand %25, %23
div 1 %27 = ine %26, %10 (0x0)