nir/opt_if: fix opt_if_merge when destination branch has a jump
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 7 Sep 2020 10:33:44 +0000 (11:33 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 8 Sep 2020 18:39:47 +0000 (18:39 +0000)
commit6cef8040672e84393e59ed6efa9953c95f5f8c92
tree6425fee65a6031c7b9fd42e3761e3815f48a14c7
parent1ed78bd24796b4c08c8451a9223a161f4787e7cf
nir/opt_if: fix opt_if_merge when destination branch has a jump

Fixes a case where opt_if_merge created code like:
if (...) {
   break;
   loop {
      ...
   }
}
which caused opt_peel_loop_initial_if to complain that the loop pre-header
wasn't a predecessor of the loop header. This patch prevents this
(invalid, I think) unreachable code from being created.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3496
Fixes: 4d3f6cb9739 ('nir: merge some basic consecutive ifs')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6633>
src/compiler/nir/nir_opt_if.c