changeset 15864:cd755faecaec

midtier: remove ReadEliminationPhase (superseded by EarlyReadEliminationPhase)
author Bernhard Urban <bernhard.urban@jku.at>
date Fri, 23 May 2014 13:22:54 +0200
parents f04a541af3c9
children 3a5ddfa22e77
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java
diffstat 3 files changed, 3 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java	Fri May 23 11:50:47 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java	Fri May 23 13:22:54 2014 +0200
@@ -84,11 +84,11 @@
             // structure changes significantly
             StructuredGraph graph = parse(snippet);
             PhaseContext context = new PhaseContext(getProviders(), new Assumptions(false));
-            new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
+            CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
+            new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
             new FloatingReadPhase().apply(graph);
             new OptimizeGuardAnchorsPhase().apply(graph);
-            new ReadEliminationPhase().apply(graph);
-            new CanonicalizerPhase(true).apply(graph, context);
+            canonicalizer.apply(graph, context);
 
             Debug.dump(graph, "After lowering");
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java	Fri May 23 11:50:47 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java	Fri May 23 13:22:54 2014 +0200
@@ -52,9 +52,6 @@
 
         if (OptFloatingReads.getValue()) {
             appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new FloatingReadPhase()));
-            if (OptReadElimination.getValue()) {
-                appendPhase(new ReadEliminationPhase());
-            }
         }
         appendPhase(new RemoveValueProxyPhase());
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java	Fri May 23 11:50:47 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.phases.common;
-
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.phases.*;
-
-public class ReadEliminationPhase extends Phase {
-
-    @Override
-    protected void run(StructuredGraph graph) {
-        for (FloatingReadNode n : graph.getNodes(FloatingReadNode.class)) {
-            if (isReadEliminable(n)) {
-                NodeMap<ValueNode> nodeMap = n.graph().createNodeMap();
-                ValueNode value = getValue(n, n.getLastLocationAccess(), nodeMap);
-                Debug.log("Eliminated memory read %1.1s and replaced with node %s", n, value);
-                graph.replaceFloating(n, value);
-            }
-        }
-    }
-
-    private static boolean isReadEliminable(FloatingReadNode n) {
-        return isWrites(n, n.getLastLocationAccess(), n.graph().createNodeBitMap());
-    }
-
-    private static boolean isWrites(FloatingReadNode n, MemoryNode lastLocationAccess, NodeBitMap visited) {
-        if (lastLocationAccess == null) {
-            return false;
-        }
-        if (visited.isMarked(ValueNodeUtil.asNode(lastLocationAccess))) {
-            return true; // dataflow loops must come from Phis assume them ok until proven wrong
-        }
-        if (lastLocationAccess instanceof ProxyNode) {
-            return isWrites(n, (MemoryNode) ((ProxyNode) lastLocationAccess).value(), visited);
-        }
-        if (lastLocationAccess instanceof WriteNode) {
-            WriteNode other = (WriteNode) lastLocationAccess;
-            return other.object() == n.object() && other.location() == n.location();
-        }
-        if (lastLocationAccess instanceof MemoryPhiNode) {
-            visited.mark(ValueNodeUtil.asNode(lastLocationAccess));
-            for (ValueNode value : ((MemoryPhiNode) lastLocationAccess).values()) {
-                if (!isWrites(n, (MemoryNode) value, visited)) {
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-    private static ValueNode getValue(FloatingReadNode n, MemoryNode lastLocationAccess, NodeMap<ValueNode> nodeMap) {
-        ValueNode exisiting = nodeMap.get(ValueNodeUtil.asNode(lastLocationAccess));
-        if (exisiting != null) {
-            return exisiting;
-        }
-        if (lastLocationAccess instanceof MemoryProxyNode) {
-            MemoryProxyNode proxy = (MemoryProxyNode) lastLocationAccess;
-            ValueNode value = getValue(n, proxy.getOriginalMemoryNode(), nodeMap);
-            return ProxyNode.forValue(value, proxy.proxyPoint(), proxy.graph());
-        }
-        if (lastLocationAccess instanceof WriteNode) {
-            return ((WriteNode) lastLocationAccess).value();
-        }
-        if (lastLocationAccess instanceof MemoryPhiNode) {
-            MemoryPhiNode phi = (MemoryPhiNode) lastLocationAccess;
-            ValuePhiNode newPhi = phi.graph().addWithoutUnique(new ValuePhiNode(n.stamp().unrestricted(), phi.merge()));
-            nodeMap.set(phi, newPhi);
-            for (ValueNode value : phi.values()) {
-                newPhi.addInput(getValue(n, (MemoryNode) value, nodeMap));
-            }
-            return newPhi;
-        }
-        throw GraalInternalError.shouldNotReachHere();
-    }
-}