Skip to content

Commit eb71a9b

Browse files
#57 bug fix - the phi elimination must use simple copy
1 parent 6ae04de commit eb71a9b

File tree

1 file changed

+3
-3
lines changed
  • optvm/src/main/java/com/compilerprogramming/ezlang/compiler

1 file changed

+3
-3
lines changed

optvm/src/main/java/com/compilerprogramming/ezlang/compiler/ExitSSA2.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ private void removePhis() {
105105
var phis = block.phis();
106106
if (phis.isEmpty())
107107
continue;
108-
// Insert copy in predecessor
108+
// Insert copy in predecessor, since we are in CSSA, this is
109+
// a simple assignment from phi input to phi var
109110
for (var phi: phis) {
110111
for (int j = 0; j < phi.numInputs(); j++) {
111112
BasicBlock pred = block.predecessor(j);
112-
var pCopyBEnd = getParallelCopyAtEnd(pred);
113113
var phiInput = phi.input(j);
114114
var phiVar = phi.value();
115-
pCopyBEnd.addCopy(phiInput,new Operand.RegisterOperand(phiVar));
115+
insertAtEnd(pred,new Instruction.Move(phiInput,new Operand.RegisterOperand(phiVar)));
116116
}
117117
}
118118
block.instructions.removeIf(instruction -> instruction instanceof Instruction.Phi);

0 commit comments

Comments
 (0)