Skip to content

nir: Skip opt_if_merge when next_if has block ending in a jump

Matt Turner requested to merge mattst88/mesa:fix-for-nir_opt_if into main

Similar to commit 6cef8040 ("nir/opt_if: fix opt_if_merge when destination branch has a jump"), we shouldn't combine if statements when the second if-then-else has a block that ends in a jump.

This fixes a case where opt_if_merge combines

    if (cond) {
        [then-block-1]
    } else {
        [else-block-1]
    }

    if (cond) {
        [then-block-2]
    } else {
        [else-block-2]
    }

where then-block-2 or else-block-2 ends in a jump. The phi nodes following the control flow will be incorrectly updated to have an input from a block that is not a predecessor.

Fixes: 4d3f6cb9 ("nir: merge some basic consecutive ifs")

Merge request reports

Loading