Re: [RFC] sparse SSA construction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 16, 2017 at 12:23 AM, Christopher Li <sparse@xxxxxxxxxxx> wrote:
> If sparse only place the phi node on where the loads are, which a lot of
> case happen to be the DF (dominance frontier). In the case that DF
> does not have loads, that is where current sparse do wrong, sparse
> does not place a phi node  there. Which violate the SSA property.

I give an example for the above situation I am talking about:

int a, b, c, d;

void foo(void)
{
  int e, f;
  if (a)
     e = b;
  else
     e = c;
  if (b)
     c = a+b;
  d = e;
}

"if (b)" is where the dominance of "e = b" and "e =c" joined.
I don't do any loading of "e" there.
To insert some blocks before using "e", I use the "if (b)".

Now let's look at the test-linearize output:
foo:
.L0:
<entry-point>
load.32     %r1(a) <- 0[a]
cbr         %r1(a), .L1, .L2

.L1:
load.32     %r2(e) <- 0[b]
phisrc.32   %phi3(b) <- %r2(e)
phisrc.32   %phi4(e) <- %r2(e)
phisrc.32   %phi6(e) <- %r2(e)
phisrc.32   %phi7(e) <- %r2(e)
br          .L3

.L2:
load.32     %r3 <- 0[c]
phisrc.32   %phi5(e) <- %r3
br          .L3

.L3:
load.32     %r4(b) <- 0[b] <========  notice no phi node here.
          It is required because here it knows which edge
          it arrived. From L1, use %r2, from L2 use %r3.


cbr         %r4(b), .L4, .L5

.L4:
add.32      %r7 <- %r1(a), %r4(b)
store.32    %r7 -> 0[c]
br          .L5

.L5:
phi.32      %r8 <- %phi4(e), %phi5(e) <====== phi node here
store.32    %r8 -> 0[d]
ret

Notice how phi node is too late in .L5.

L5 does not have the edge information how
L1 and L2 joined. That information is at L3.

The phi source is not going to remedy this.
Because phi source is not going to know how
the phi source is going to join other phi source in
the later blocks.

The edge information is the one that is critically
missing here.

Actually, if we do SSA properly, we don't need the
phi source at all. We can directly use the source of
the phisource, which is %r2 and %r3.
if arrive in L3 from L1 use %r2, from L2 using %r3.


Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux