[LLVMdev] Copy Instructions?
David Greene
dag at cray.com
Wed Jan 28 09:06:14 PST 2009
On Tuesday 27 January 2009 18:28, Eli Friedman wrote:
> You can use a no-op bitcast for scalars, but there isn't any reliable
> way to do it for all first-class values.
Guh.
> That said, I don't quite follow the issue. This is SSA, so the only way a
> value can change is if you change the code.
This isn't (yet) SSA. This is mem2reg turning things into SSA.
> I'm not really following what the issue is in this testcase, though,
> so I could be missing something. The way you're describing it,
> mem2reg appears to be working as intended; the correct completion is
> in fact as follows:
> // x = phi(x.0, expr)
> // y = phi(y.0, x)
Yes, that's what mem2reg ends up with.
> > In this particular example another solution would be to reorder the phis
> > but I don't think that will work in the general case.
>
> PHI nodes don't have an ordering, at least conceptually; they're not
> real instructions.
They don't have an ordering? So what does your above code mean? I would have
expected it to mean that y is either the value of y.0 or the value from the
phi immediate preceeding it. Is that not correct?
If my understanding is correct then the code is wrong. The original code
looks something like this:
x = 0
y = 0
do
[...use x and y...]
y = x
x = expr
end do
So y should get the previous value of x, not the value updated at the end of
the loop body.
If there truly is no ordering then perhaps Prakash is correct and this is an
out-of-SSA problem. I'd appreciate your opinion on this. I read the Briggs
SPE paper a long time ago. Time to dust it off.
-Dave
More information about the llvm-dev
mailing list