Skip to content

aco: make sure to break the loop when the normal continue block is unreachable

In a situation like:

loop {
    if (cond) {
        ...
        break
    } else {
        ...
        break
    }
}

the "normal continue" block is unreachable and if the loop mask is empty this can lead to an infinite loop. Make sure to break the loop if the exec mask is empty to avoid that.

This pattern should also be optimized in NIR but that's something for later (it should help to reduce code size with Detroit and RDR2).

This fixes a GPU hang with Red Dead Redemption 2 (tested on GFX9).

vkpipeline-db stats (GFX9):
Totals from affected shaders:
SGPRS: 211552 -> 211584 (0.02 %)
VGPRS: 165712 -> 165712 (0.00 %)
Spilled SGPRs: 49388 -> 50620 (2.49 %)
Scratch size: 0 -> 0 (0.00 %) dwords per thread
Code Size: 27230572 -> 27598536 (1.35 %) bytes
Max Waves: 6314 -> 6314 (0.00 %)

This only affects Detroit Become Human.

Merge request reports