[Mesa-dev] [PATCH] glsl: fix loop analysis of loop terminators

Timothy Arceri tarceri at itsqueeze.com
Wed Sep 6 22:48:27 UTC 2017


On 07/09/17 06:59, Matt Turner wrote:
> I feel like the commit message is missing some important information.
> What does this fix? Do we have a piglit test? I don't see one from
> you. I see that someone has replied with a Tested-by, so presumably
> they know what it's intended to fix.
> 

Huh??? Are you winding me up?

"This code incorrectly assumed that loop terminators will always be
at the start of the loop. Fortunately we *seem* to avoid any bugs
because the unrolling code loops over and correctly handles the
terminators.

However the incorrect analysis can result in loops not being
unrolled at all.

... examples of loops that are unrolled/not unrolled ..."

You can't write a piglit test to detect if a loop is unrolled or not, 
only if it was unrolled correctly. I wrote a bunch of the former when 
implementing unrolling in nir.

Anyway this patch broke one of those tests as per my reply shortly after 
sending it. Further examination shows there are more bugs and 
limitations in the GLSL IR version of unrolling. I've updated the pass 
to be more like the NIR pass but now I'm hitting bugs further down the 
line due to the us exiting the GLIR optimisation loop after only a 
single iteration, it seems TGSI or LLVM doesn't handle the unrolled loop 
without the redundant ifs cleaned up in some cases.



More information about the mesa-dev mailing list