On Mon, Aug 29, 2016 at 9:06 PM, Timothy Arceri
<timothy.arc...@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.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to