nir: fix selection of loop terminator when two or more have the same limit
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 4 Jun 2018 06:26:46 +0000 (16:26 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Sat, 30 Jun 2018 00:13:03 +0000 (10:13 +1000)
commit463f849097193ad20e7622ddd740fd15b96f4277
tree81460ee57bb8f946e0620257d6188add2f43e834
parent18293be62282b5f02ffabccdb8597a3e217b55e8
nir: fix selection of loop terminator when two or more have the same limit

We need to add loop terminators to the list in the order we come
across them otherwise if two or more have the same exit condition
we will select that last one rather than the first one even though
its unreachable.

This fix is for simple unrolls where we only have a single exit
point. When unrolling these type of loops the unreachable
terminators and their unreachable branch are removed prior to
unrolling. Because of the logic change we also switch some
list access in the complex unrolling logic to avoid breakage.

Fixes: 6772a17acc8e ("nir: Add a loop analysis pass")

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_loop_analyze.c
src/compiler/nir/nir_opt_loop_unroll.c