nir/loop_unroll: clean up after complex_unroll_single_terminator()
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 18 Jul 2022 09:18:15 +0000 (19:18 +1000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 20 Jul 2022 03:47:45 +0000 (03:47 +0000)
commitd1e36634bdf3178f8ae7290de14bb9122cebe550
tree6f5c1598215770c7771988ddded1566d33ba7823
parentbfebf51571e3f958bf74e9d90cb095e4fced8c06
nir/loop_unroll: clean up after complex_unroll_single_terminator()

Previously we would just unroll the loop one extra iteration and let
other optimisation passes clean up the mess. This worked to a degree
but if the loop happened to be nested inside another loop we would
end up with phi chains that would block other passes from being able
to do the cleanup.

With this commit we explicitly clone the variables create by lcsaa
and insert them directly in the last continue branch after we are done
unrolling. With this optimisation passes can recognise both sides
of the if output the same values and can progress further.

Help with the issues described in:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/6051

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17611>
src/compiler/nir/nir_opt_loop_unroll.c