Skip to content

nir/loop_analyze: Treat do{}while(false) loops as 0 iterations

Loops like:

block block_0:
vec1 32 ssa_2 = load_const (0x00000020)
vec1 32 ssa_3 = load_const (0x00000001)
loop {
    vec1 32 ssa_7 = phi block_0: ssa_3, block_4: ssa_9
    vec1 1 ssa_8 = ige ssa_2, ssa_7
    if ssa_8 {
        break
    } else {
    }
    vec1 32 ssa_9 = iadd ssa_7, ssa_1
}

Were treated as having more than 1 iteration and after unrolling produced wrong results, however such loop will exit during the first iteration if not unrolled.

So we check if loop will actually loop.

Fixes tests/shaders/glsl-fs-loop-while-false-02.shader_test see piglit!115 (merged)

CI results: https://mesa-ci.01.org/global_logic/builds/207/group/63a9f0ea7bb98050796b649e85481845#subgroups - no related failures

Edited by Danylo Piliaiev

Merge request reports

Loading