# HG changeset patch # User Josef Eisl # Date 1402498947 -7200 # Node ID f8ba57019a5d55ab475d6ed2179dd7878afcea9d # Parent ef641ba1fb69255fad34823580c07d5ea4e9d1f8 LSRA spill optimization: move spill position to the dominator if at spill interval. diff -r ef641ba1fb69 -r f8ba57019a5d 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 14:51:27 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed Jun 11 17:02:27 2014 +0200 @@ -1975,9 +1975,16 @@ if (interval != null && interval.isSplitParent() && interval.spillState() == SpillState.SpillInDominator) { AbstractBlock defBlock = blockForId(interval.spillDefinitionPos()); AbstractBlock spillBlock = null; + Interval firstSpillChild = null; try (Indent indent = Debug.logAndIndent("interval %s (%s)", interval, defBlock)) { for (Interval splitChild : interval.getSplitChildren()) { if (isStackSlot(splitChild.location())) { + if (firstSpillChild == null || splitChild.from() < firstSpillChild.from()) { + firstSpillChild = splitChild; + } else { + assert firstSpillChild.from() < splitChild.from(); + } + // 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); @@ -1999,6 +2006,17 @@ spillBlock = moveSpillOutOfLoop(defBlock, spillBlock); } + /* + * If the spill block is the begin of the first split child (aka the value + * is on the stack) spill in the dominator. + */ + assert firstSpillChild != null; + if (!defBlock.equals(spillBlock) && spillBlock.equals(blockForId(firstSpillChild.from()))) { + AbstractBlock dom = spillBlock.getDominator(); + Debug.log("Spill block (%s) is the beginning of a spill child -> use dominator (%s)", spillBlock, dom); + spillBlock = dom; + } + if (!defBlock.equals(spillBlock)) { assert dominates(defBlock, spillBlock); betterSpillPos.increment();