[Mesa-dev] [PATCH] glsl: fix infinite loop caused by bug in loop unrolling pass

Ian Romanick idr at freedesktop.org
Mon Mar 26 16:48:16 UTC 2018


On 03/25/2018 04:31 PM, Timothy Arceri wrote:
> 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 nesed inside multiple ifs which loop analysis is unable

           nested

> 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"
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=105670

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105670

Based on my understanding of this code, I think this is correct.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>  src/compiler/glsl/loop_unroll.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/loop_unroll.cpp b/src/compiler/glsl/loop_unroll.cpp
> index 6e06a30fb91..f6efe6475a0 100644
> --- a/src/compiler/glsl/loop_unroll.cpp
> +++ b/src/compiler/glsl/loop_unroll.cpp
> @@ -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 =
> 



More information about the mesa-dev mailing list