glsl: fix infinite loop caused by bug in loop unrolling pass
authorTimothy Arceri <tarceri@itsqueeze.com>
Sun, 25 Mar 2018 23:31:26 +0000 (10:31 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 26 Mar 2018 22:15:02 +0000 (09:15 +1100)
Just checking for 2 jumps is not enough to be sure we can do a
complex loop unroll. We need to make sure we also have also found
2 loop terminators.

Without this we were attempting to unroll a loop where the second
jump was nested inside multiple ifs which loop analysis is unable
to detect as a terminator. We ended up splicing out the first
terminator but failed to actually unroll the loop, this resulted
in the creation of a possible infinite loop.

Fixes: 646621c66da9 "glsl: make loop unrolling more like the nir unrolling path"
Tested-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105670

src/compiler/glsl/loop_unroll.cpp

index 6e06a30fb9150f95a3f8042357da1c15e9bcb33a..f6efe6475a0829df9a8ac96a71c78af335260ffd 100644 (file)
@@ -519,7 +519,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
     * isn't any additional unknown terminators, or any other jumps nested
     * inside futher ifs.
     */
-   if (ls->num_loop_jumps != 2)
+   if (ls->num_loop_jumps != 2 || ls->terminators.length() != 2)
       return visit_continue;
 
    ir_instruction *first_ir =