# HG changeset patch # User Josef Eisl # Date 1402941853 -7200 # Node ID d908e75a099044093f264e2544a99495506e39cc # Parent 74e93f5ba4f3a6d1e74122456d489426f105e328 LSRA spill optimization: insert dominator spill move after data flow resolution moves. diff -r 74e93f5ba4f3 -r d908e75a0990 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Jun 11 20:24:10 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Mon Jun 16 20:04:13 2014 +0200 @@ -614,7 +614,22 @@ assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlot(toLocation) : "to operand must be a stack slot"; - insertionBuffer.append(j + 1, ir.getSpillMoveFactory().createMove(toLocation, fromLocation)); + if (interval.spillState() == SpillState.SpillInDominator) { + /* + * SpillInDominator spill positions are always at the beginning + * of a basic block. We need to skip the moves inserted by data + * flow resolution to ensure data integrity. + */ + assert isBlockBegin(opId) && j == 0 : "SpillInDominator spill position must be at the beginning of a block!"; + int pos = 1; + while (instructions.get(pos).id() == -1) { + pos++; + } + assert pos < instructions.size() : String.format("Cannot move spill move out of the current block! (pos: %d, #inst: %d, block: %s", pos, instructions.size(), block); + insertionBuffer.append(pos, ir.getSpillMoveFactory().createMove(toLocation, fromLocation)); + } else { + insertionBuffer.append(j + 1, ir.getSpillMoveFactory().createMove(toLocation, fromLocation)); + } Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); }