1

I've been learning about ssa (static single assignment form), and I was given the following graph with phi functions inserted, but the graph hasn't been renamed:

The given ssa graph

I had to rename the variables, and this is what I got:

The ssa graph that I converted

I am very unsure that this is correct. Did I rename the variables correctly? Is this minimal ssa? I am using this algorithm from here (Cytron, et. al's paper) to rename the variables. Please help! :)

xilpex
  • 3,097
  • 2
  • 14
  • 45
  • 1
    I don't understand the graph you were given. Why is the label `L1` in the middle of a basic block? Does that indicate that `goto L1` would jump into the middle of the block (skipping the phi nodes)? And what are the values of t1 etc when coming from the initial block (which doesn't give any value to them)? – sepp2k Jul 28 '20 at 14:47
  • @sepp2k -- Thank you for taking notice :) -- No those aren't of any significance... They just aid me. – xilpex Jul 28 '20 at 17:15
  • I'm sorry, but I'm not quite sure how to take your reply. What isn't of any significance? It seems to me that whether `goto L1` jumps over the phi nodes or not and what the initial values of `t1` through `t3` are, are pretty significant. Like the line `t1_0 <- phi(t1_0, t1_1)` is ill-formed because `t1_0` isn't defined in the block before the loop, but I can't tell you what the correct version would be because I don't even understand what `t1 <- phi(t1, t1)` was supposed to do in the first place. – sepp2k Jul 28 '20 at 18:52
  • @sepp2k -- I meant the gotos and labels (`goto L1` and label `L1`). – xilpex Jul 28 '20 at 19:00
  • Also, is `t1_0 <- phi(t1_0, t1_1)` incorrect? – xilpex Jul 28 '20 at 19:01

1 Answers1

1

No, your graph is not correct. The phi-functions and renaming for x and y are correct, the problem is the temporary variables t1 through t3. These variable are dead when the block L1 is entered and does not require any phi-functions at all. If you insist on having phi-functions for these variables you must assume that the variables exist and have som indeterminate value when the graph is entered. Let t1_0, t2_0 and t3_0 be those values and update the renamed graph accordingly.

Johan
  • 3,667
  • 6
  • 20
  • 25
  • Ok, thanks... One more thing: I constructed pruned ssa, and the phi function for `y` was gone (Presumably because it wasn't used in block `L1`). Did I get this correct? – xilpex Aug 04 '20 at 20:57
  • @xilpex You need a phi-function for `y` in `L1` since this variable has different definitions depending on which incoming edge you enter via. – Johan Aug 04 '20 at 21:25
  • Ah, yes-- but if the `y` wasn't used in block `L2`, the phi function wouldn't be required right? – xilpex Aug 04 '20 at 21:51
  • It is needed anyway since `y` is not dead at the entry of `L1` (it is used when computing `t2`) and has different definitions depending on how you reach `L1`. Phi-functions are used for merging _incoming_ flow. – Johan Aug 05 '20 at 05:48
  • What is constructed is SSA on minimal but not pruned form. In this representation phi functions are inserted regardless of whether the variables are live at that point or not. – Björn Lindqvist May 03 '22 at 14:27