diff graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java @ 19721:b503dd4e723c

Perform full schedule for conditional elimination only in a phase where floating guards are available.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 09 Mar 2015 12:03:48 +0100
parents 055a095424a7
children 1a9bfa2c3cc9
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java	Mon Mar 09 11:33:09 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java	Mon Mar 09 12:03:48 2015 +0100
@@ -44,8 +44,10 @@
 
     private static final DebugMetric metricStampsRegistered = Debug.metric("StampsRegistered");
     private static final DebugMetric metricStampsFound = Debug.metric("StampsFound");
+    private final boolean fullSchedule;
 
-    public DominatorConditionalEliminationPhase() {
+    public DominatorConditionalEliminationPhase(boolean fullSchedule) {
+        this.fullSchedule = fullSchedule;
     }
 
     private static final class InfoElement {
@@ -88,12 +90,29 @@
 
     @Override
     protected void run(StructuredGraph graph) {
-        SchedulePhase schedule = new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST);
-        schedule.apply(graph);
-        ControlFlowGraph cfg = schedule.getCFG();
-        cfg.computePostdominators();
-        Instance instance = new Instance(graph, b -> schedule.getBlockToNodesMap().get(b), n -> schedule.getNodeToBlockMap().get(n));
-        instance.processBlock(cfg.getStartBlock());
+
+        Function<Block, Iterable<? extends Node>> blockToNodes;
+        Function<Node, Block> nodeToBlock;
+        Block startBlock;
+
+        if (fullSchedule) {
+            SchedulePhase schedule = new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST);
+            schedule.apply(graph);
+            ControlFlowGraph cfg = schedule.getCFG();
+            cfg.computePostdominators();
+            blockToNodes = b -> schedule.getBlockToNodesMap().get(b);
+            nodeToBlock = n -> schedule.getNodeToBlockMap().get(n);
+            startBlock = cfg.getStartBlock();
+        } else {
+            ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true);
+            cfg.computePostdominators();
+            blockToNodes = b -> b.getNodes();
+            nodeToBlock = n -> cfg.blockFor(n);
+            startBlock = cfg.getStartBlock();
+        }
+
+        Instance instance = new Instance(graph, blockToNodes, nodeToBlock);
+        instance.processBlock(startBlock);
     }
 
     private static class Instance {