|
4 | 4 |
|
5 | 5 | /** |
6 | 6 | * Implement method to exit SSA by converting to conventional SSA, |
7 | | - * without coalescing. This is the basic form. |
| 7 | + * without coalescing. This is the basic form - it creates extra copies but |
| 8 | + * the transformation is simple and correct, and does not suffer from the lost copy or |
| 9 | + * swap problem. |
8 | 10 | * |
9 | | - * This is essentially Method 1 described by |
| 11 | + * The simple conversion is essentially Method 1 described by |
10 | 12 | * Translating Out of Static Single Assignment Form |
11 | 13 | * Vugranam C. Sreedhar, Roy Dz-Ching Ju, David M. Gillies, and Vatsa Santhanam |
12 | 14 | * |
|
17 | 19 | * Benoit Boissinot, Alain Darte, Fabrice Rastello, Benoît Dupont de Dinechin, Christophe Guillon |
18 | 20 | * |
19 | 21 | * The Boissinot paper gives a more correct description, discussing the need for parallel copy |
20 | | - * and sequencing the parallel copy, but the paper describes a |
21 | | - * more complex approach that performs coalescing. |
| 22 | + * and sequencing the parallel copy. Much of the Boissinot paper is about optimizing away any extra copies, but |
| 23 | + * it seems to me that the Briggs algorithm achieves that anyway while being simpler |
| 24 | + * to implement. |
22 | 25 | * |
23 | 26 | * Engineering a Compiler, 3rd edition, describes the simpler form - omitting the coalescing part. |
24 | | - * |
25 | 27 | * Our implementation is similar to EaC. |
26 | 28 | * |
27 | 29 | * We do not use the sequencing algo described in Boissinot paper. Instead, we use: |
@@ -115,12 +117,14 @@ private void makeConventionalSSA() { |
115 | 117 | BasicBlock pred = block.predecessor(j); |
116 | 118 | var pCopyBEnd = getParallelCopyAtEnd(pred); |
117 | 119 | var oldInput = phi.input(j); |
118 | | - var newInput = function.registerPool.newTempReg(oldInput.type); |
| 120 | + var newInput = oldInput instanceof Operand.RegisterOperand regInput ? |
| 121 | + function.registerPool.newTempReg(regInput.reg.name(), oldInput.type) : |
| 122 | + function.registerPool.newTempReg(oldInput.type); |
119 | 123 | pCopyBEnd.addCopy(oldInput,new Operand.RegisterOperand(newInput)); |
120 | 124 | phi.replaceInput(j,newInput); |
121 | 125 | } |
122 | 126 | var oldPhiVar = phi.value(); |
123 | | - var newPhiVar = function.registerPool.newTempReg(oldPhiVar.type); |
| 127 | + var newPhiVar = function.registerPool.newTempReg(oldPhiVar.name(), oldPhiVar.type); |
124 | 128 | phi.replaceValue(newPhiVar); |
125 | 129 | var pCopyBBegin = getParallelCopyAtBegin(block); |
126 | 130 | pCopyBBegin.addCopy(new Operand.RegisterOperand(newPhiVar),new Operand.RegisterOperand(oldPhiVar)); |
|
0 commit comments