nir/opt_dead_cf: Run dead_cf_block while it makes progress

Previously, nir_opt_dead_cf could skip dead CF nodes because overwriting
cur after dead_cf_block is not enough to cover the whole CF list.
foreach_list_typed would select the next node, skipping the node that
previously made progress:

block 1
if (true) {}
block 2
if (true) {}
block 3
if (true) {}

Would turn into:

block 1, then, block 2
if (true) { }
block 3, then

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22064>
This commit is contained in:
Konstantin Seurer 2023-07-10 21:40:44 +02:00 committed by Marge Bot
parent 6532751e4d
commit 4b5737b785

View file

@ -311,7 +311,7 @@ dead_cf_list(struct exec_list *list, bool *list_ends_in_jump)
switch (cur->type) {
case nir_cf_node_block: {
nir_block *block = nir_cf_node_as_block(cur);
if (dead_cf_block(block)) {
while (dead_cf_block(block)) {
/* We just deleted the if or loop after this block, so we may have
* deleted the block before or after it -- which one is an
* implementation detail. Therefore, to recover the place we were