Straight-line single assignment in C--

Hello all, I was wondering if the following style of register assignment ever shows up in C-- code generated by GHC: a = R1 I32[a] = 1 a = R2 I32[a] = 2 That is to say, there are two disjoint live ranges of a: we could rename all instances of a in the first and second lines to something different without affecting the semantics (although maybe affecting register allocation and stack spilling.) asdf = R1 I32[asdf] = 1 a = R2 I32[a] = 2 But C-- is not in SSA form, and even when no loops are involved it seems that some naughty code generator could reuse a variable. This is pretty inconvenient, because I want to record this information a = R1 // used only once I32[a] = 1 a = R2 // used only once I32[a] = 2 in a map: a -> used only once But since the register names go all the same place this may end in tears. If multiple assignment is rare enough in straight line code, I might be able to take the conservative approach and just say a -> used multiple times Which I don't think will cause any problems in the inlining step later. But I don't have a good sense for this. Edward

Excerpts from Edward Z. Yang's message of Fri Jan 20 23:44:02 -0500 2012:
If multiple assignment is rare enough in straight line code, I might be able to take the conservative approach and just say
a -> used multiple times
Which I don't think will cause any problems in the inlining step later. But I don't have a good sense for this.
I realized the answer to my question, which is YES. In particular, the spill-reload step will result in this happening. Back to the drawing board... Edward

On 21/01/2012 20:39, Edward Z. Yang wrote:
Excerpts from Edward Z. Yang's message of Fri Jan 20 23:44:02 -0500 2012:
If multiple assignment is rare enough in straight line code, I might be able to take the conservative approach and just say
a -> used multiple times
Which I don't think will cause any problems in the inlining step later. But I don't have a good sense for this.
I realized the answer to my question, which is YES. In particular, the spill-reload step will result in this happening. Back to the drawing board...
In the old code generator we generated SSA code, by virtue of (a) never having loops and (b) never reusing LocalRegs. In fact I think the mini-inliner in CmmOpt relies on this property. It's a useful property to have - perhaps we should have it in the new codegen too? (modulo loops of course, I'm not suggesting we introduce Phi nodes) Cheers, Simon
participants (2)
-
Edward Z. Yang
-
Simon Marlow