nir/cf: Fix unlink_block_successors to actually unlink the second one.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 2 Sep 2015 05:56:29 +0000 (22:56 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 23 Sep 2015 18:00:00 +0000 (11:00 -0700)
Calling unlink_blocks(block, block->successors[0]) will successfully
unlink the first successor, but then will shift block->successors[1]
down to block->successor[0].  So the successors[1] != NULL check will
always fail.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/glsl/nir/nir_control_flow.c

index 87bc7163efda4017fca9d208fa81776935020ff8..55d0689c45e2baf53d51bfb53e1c3e1e368350cc 100644 (file)
@@ -99,10 +99,10 @@ unlink_blocks(nir_block *pred, nir_block *succ)
 static void
 unlink_block_successors(nir_block *block)
 {
-   if (block->successors[0] != NULL)
-      unlink_blocks(block, block->successors[0]);
    if (block->successors[1] != NULL)
       unlink_blocks(block, block->successors[1]);
+   if (block->successors[0] != NULL)
+      unlink_blocks(block, block->successors[0]);
 }
 
 static void