Re: Question about Sparse Linear form and pseudos

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

 



On Sun, Aug 20, 2017 at 03:54:47PM +0100, Dibyendu Majumdar wrote:
> Hi,
> 
> I am trying to get to grips with the Sparse Linear format and the use
> of pseudos.
> 
> 1) A Sparse document says that pseudos are akin to SSA variables. Is
> that a true statement - i.e. do pseudos follow the discipline that
> only one assignment to a pseudo is allowed. As pseudos have also
> different sub-types - does this statement apply to all pseudo types or
> only some sub types?
> 
> 2) In a recent conversation it was stated that the baseline Linear
> output from Sparse is already in SSA form. That implies that all
> pseudos used are in SSA form already. However we know that in the
> baseline line IR phi nodes may not be present. In LLVM the initial IR
> lacks phi nodes too - instead local stack memory and load/store
> sequences are used. However LLVM IR is still SSA at this stage. When
> it is said that the baseline Linear IR is already SSA is it in this
> sense?

One way to answer this with few words is to look at what's happening
to a variable assigned in different paths in a simple example:

	int f(void);

	int foo(int p)
	{
		int a;

		if (p) {
			a = 0;
			a++;
		} else {
			a = f();
		}

		return a;
	}


Just after linearization:
	foo:
	.L0:
		<entry-point>
		store.32    %arg1 -> 0[p]
		load.32     %r1 <- 0[p]
		cbr         %r1, .L1, .L2

	.L1:
		store.32    $0 -> 0[a]
		load.32     %r2 <- 0[a]
		add.32      %r3 <- %r2, $1
		store.32    %r3 -> 0[a]
		br          .L3

	.L2:
		call.32     %r4 <- f
		store.32    %r4 -> 0[a]
		br          .L3

	.L3:
		load.32     %r5 <- 0[a]
		ret.32      %r5


After conversion to SSA form:
	foo:
	.L0:
		<entry-point>
		cbr         %arg1, .L1, .L2

	.L1:
		add.32      %r3(a) <- $0, $1
		phisrc.32   %phi2(a) <- %r3(a)
		br          .L3

	.L2:
		call.32     %r4 <- f
		phisrc.32   %phi3(a) <- %r4
		br          .L3

	.L3:
		phi.32      %r5 <- %phi2(a), %phi3(a)
		ret.32      %r5


After simplification:
	foo:
	.L0:
		<entry-point>
		cbr         %arg1, .L1, .L2

	.L1:
		phisrc.32   %phi2(a) <- $1
		br          .L3

	.L2:
		call.32     %r4 <- f
		phisrc.32   %phi3(a) <- %r4
		br          .L3

	.L3:
		phi.32      %r5 <- %phi2(a), %phi3(a)
		ret.32      %r5


After going out of SSA (currently not used):
	foo:
	.L0
		<entry-point>
		cbr         %arg1, .L1, .L2

	.L1
		copy.32     %r7 <- $1
		br          .L3

	.L2
		call.32     %r7 <- f
		br          .L3

	.L3
		ret.32      %r7


-- Luc
--
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