nir/opt_loop: Fix handling else-breaks in merge_terminators

If both breaks are in the else branch, we have to use iand.

Fixes: 9995f33 ("nir: add merge loop terminators optimisation")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11726
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30850>
This commit is contained in:
Konstantin Seurer
2024-08-26 14:01:04 +02:00
committed by Marge Bot
parent 44e1cf2748
commit 0fc3c52e43
+7 -1
View File
@@ -557,7 +557,13 @@ merge_terminators(nir_builder *b, nir_if *dest_if, nir_if *src_if)
}
b->cursor = nir_before_src(&dest_if->condition);
nir_def *new_c = nir_ior(b, dest_if->condition.ssa, src_if->condition.ssa);
nir_def *new_c = NULL;
if (then_break)
new_c = nir_ior(b, dest_if->condition.ssa, src_if->condition.ssa);
else
new_c = nir_iand(b, dest_if->condition.ssa, src_if->condition.ssa);
nir_src_rewrite(&dest_if->condition, new_c);
}