Skip to content
Snippets Groups Projects
Commit 97792279 authored by Danylo Piliaiev's avatar Danylo Piliaiev :flag_ua: Committed by Dylan Baker
Browse files

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

Signed-off-by: default avatarDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: default avatarTimothy Arceri <tarceri@itsqueeze.com>
(cherry picked from commit e71fc7f2)
parent 3771534b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment