[Mesa-dev] [PATCH 12/13] nir: add a loop unrolling pass
Matt Turner
mattst88 at gmail.com
Tue Aug 30 04:40:15 UTC 2016
On Mon, Aug 29, 2016 at 9:06 PM, Timothy Arceri
<timothy.arceri at collabora.com> wrote:
> Can't the phi have more than one source from before the loop? e.g
>
> int i = 0;
> if (somthing)
> i = 1;
> else
> i = 2;
>
> for ( ; i < 5; i++)
> do_stuff(i);
In fact, no. :)
NIR's control flow avoids so-called "critical edges" by ensuring that
all if/else must be preceded by a single basic block and followed by a
single basic block. It simplifies a lot of situations. This invariant
and a few more are documented at the top of nir_control_flow.c.
In your example, there will be a basic block between the end of the
if/else construct and the beginning of the loop which will contain a
phi node for i.
phi nodes only have as many sources as its containing basic block has
incoming edges. There are only two ways (that I can think of) that a
block may have more than two incoming edges in NIR: multiple break or
continue statements in a loop.
More information about the mesa-dev
mailing list