# HG changeset patch # User Josef Eisl # Date 1402511050 -7200 # Node ID 74e93f5ba4f3a6d1e74122456d489426f105e328 # Parent 73d7935be896b67d165f27175a3a15ed0838df9b LSRA spill optimization: consider all spill blocks not only use positions. diff -r 73d7935be896 -r 74e93f5ba4f3 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 19:22:36 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Jun 11 20:24:10 2014 +0200 @@ -1995,13 +1995,14 @@ } // iterate all blocks where the interval has use positions for (AbstractBlock splitBlock : blocksForSplitChild(splitChild)) { - assert dominates(defBlock, splitBlock) : String.format("Definition does not dominate the spill block %s !dom %s (interval %s)", defBlock, splitBlock, interval); - Debug.log("Split interval %s, block %s", splitChild, splitBlock); - if (spillBlock == null) { - spillBlock = splitBlock; - } else { - spillBlock = nearestCommonDominator(spillBlock, splitBlock); - assert spillBlock != null; + if (dominates(defBlock, splitBlock)) { + Debug.log("Split interval %s, block %s", splitChild, splitBlock); + if (spillBlock == null) { + spillBlock = splitBlock; + } else { + spillBlock = nearestCommonDominator(spillBlock, splitBlock); + assert spillBlock != null; + } } } } @@ -2053,41 +2054,35 @@ */ private class UseBlockIterator implements Iterator> { - int nextOpId; - Interval interval; - Range currentRange; + Range range; + AbstractBlock block; public UseBlockIterator(Interval interval) { - // the first use position is the begin of the interval - nextOpId = interval.from(); - this.interval = interval; - this.currentRange = interval.first(); + range = interval.first(); + block = blockForId(range.from); } public AbstractBlock next() { - AbstractBlock block = blockForId(nextOpId); - + AbstractBlock currentBlock = block; int nextBlockIndex = block.getLinearScanNumber() + 1; if (nextBlockIndex < sortedBlocks.size()) { - int from = getFirstLirInstructionId(sortedBlocks.get(nextBlockIndex)); - assert from > nextOpId : "cannot go backwards"; - assert from > maxOpId() || isBlockBegin(from) : "nextOpId is not a block begin"; - assert from > maxOpId() || blockForId(from).getLinearScanNumber() == block.getLinearScanNumber() + 1 : "nextOpId is not the beginning of the next block"; - nextOpId = interval.nextUsage(RegisterPriority.None, from); - if (nextOpId > currentRange.from) { - // jump to next range - nextOpId = currentRange.from; - currentRange = currentRange.next; + block = sortedBlocks.get(nextBlockIndex); + if (range.to < getFirstLirInstructionId(block)) { + range = range.next; + if (range == Range.EndMarker) { + block = null; + } else { + block = blockForId(range.from); + } } } else { - // already at last the last block - nextOpId = Integer.MAX_VALUE; + block = null; } - return block; + return currentBlock; } public boolean hasNext() { - return nextOpId < interval.to(); + return block != null; } }