Skip to content

nir/loop_unroll: Fix do{} while(false) loops unrolling

Danylo Piliaiev requested to merge GL/mesa:fix/while-false-loops-unroll into master

Without loop_prepare_for_unroll loops are losing phis. Which leads to using undefined values later on.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111411
Fixes: 5db98195 "nir: add loop unroll support for wrapper loops"

Let's say we have such loop:

loop {
    block block_2:
    /* preds: block_1 */
    vec1 32 ssa_9 = phi block_1: ssa_4
    vec1 32 ssa_10 = deref_var &constarray_0_4 (uniform int[2]) 
    vec1 32 ssa_11 = deref_array &(*ssa_10)[ssa_9] (uniform int) /* &constarray_0_4[ssa_9] */
    vec1 32 ssa_12 = intrinsic load_deref (ssa_11) (0) /* access=0 */
    vec1 1 ssa_13 = load_const (true)
    break
    /* succs: block_3 */
}

Without the commit only part after the ssa_9 was extracted:

    vec1 32 ssa_10 = deref_var &constarray_0_4 (uniform int[2]) 
    vec1 32 ssa_11 = deref_array &(*ssa_10)[ssa_9] (uniform int) /* &constarray_0_4[ssa_9] */
    vec1 32 ssa_12 = intrinsic load_deref (ssa_11) (0) /* access=0 */
    vec1 1 ssa_13 = load_const (true)

And the loop with ssa_9 was removed.

See piglit!115 (merged) for tests.

Edited by Danylo Piliaiev

Merge request reports

Loading