Skip to content

panvk: Add NIR Loop Invariant Condition Removal pass

What does this MR do and why?

Adds a NIR Loop Invariant Condition Removal (licr) optimization pass for removing loop invariant conditions by replacing them with false/true depending on where the loop breaks. This is done as any invariant condition must in all cases break the loop as the loop will be infinite otherwise.

Crucially, this works around a limitation in Valhall where invocations of vertex shaders on non-existing vertices might lead to infinite loops in cases with invariant conditions (IDVS is always invoked in batches of four threads in Valhall). This happens for the CTS test dEQP-VK.glsl.loops.special.do_while_dynamic_iterations.dowhile_trap_vertex.

While the current implementation works for the affected CTS tests, I suspect there are better ways to implement this (I'm not all that experienced with NIR, so I suspect I've overlooked quite a few things). I'm therefore looking for input on how to properly implement this pass.

Merge request reports

Loading