Search in sources :

Example 46 with LoopBeginNode

use of org.graalvm.compiler.nodes.LoopBeginNode in project graal by oracle.

the class GraphUtil method checkRedundantProxy.

public static void checkRedundantProxy(ProxyNode vpn) {
    if (vpn.isDeleted()) {
        return;
    }
    AbstractBeginNode proxyPoint = vpn.proxyPoint();
    if (proxyPoint instanceof LoopExitNode) {
        LoopExitNode exit = (LoopExitNode) proxyPoint;
        LoopBeginNode loopBegin = exit.loopBegin();
        Node vpnValue = vpn.value();
        for (ValueNode v : loopBegin.stateAfter().values()) {
            ValueNode v2 = v;
            if (loopBegin.isPhiAtMerge(v2)) {
                v2 = ((PhiNode) v2).valueAt(loopBegin.forwardEnd());
            }
            if (vpnValue == v2) {
                Collection<PhiNode> phiUsages = vpn.usages().filter(PhiNode.class).snapshot();
                Collection<ProxyNode> proxyUsages = vpn.usages().filter(ProxyNode.class).snapshot();
                vpn.replaceAtUsagesAndDelete(vpnValue);
                for (PhiNode phi : phiUsages) {
                    checkRedundantPhi(phi);
                }
                for (ProxyNode proxy : proxyUsages) {
                    checkRedundantProxy(proxy);
                }
                return;
            }
        }
    }
}
Also used : ProxyNode(org.graalvm.compiler.nodes.ProxyNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) VirtualArrayNode(org.graalvm.compiler.nodes.virtual.VirtualArrayNode) GuardNode(org.graalvm.compiler.nodes.GuardNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 47 with LoopBeginNode

use of org.graalvm.compiler.nodes.LoopBeginNode in project graal by oracle.

the class FloatingReadPhase method processLoop.

private EconomicSet<LocationIdentity> processLoop(HIRLoop loop, EconomicMap<LoopBeginNode, EconomicSet<LocationIdentity>> modifiedInLoops) {
    LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
    EconomicSet<LocationIdentity> result = modifiedInLoops.get(loopBegin);
    if (result != null) {
        return result;
    }
    result = EconomicSet.create(Equivalence.DEFAULT);
    for (Loop<Block> inner : loop.getChildren()) {
        result.addAll(processLoop((HIRLoop) inner, modifiedInLoops));
    }
    for (Block b : loop.getBlocks()) {
        if (b.getLoop() == loop) {
            processBlock(b, result);
        }
    }
    modifiedInLoops.put(loopBegin, result);
    return result;
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LocationIdentity(org.graalvm.word.LocationIdentity) Block(org.graalvm.compiler.nodes.cfg.Block) HIRLoop(org.graalvm.compiler.nodes.cfg.HIRLoop)

Example 48 with LoopBeginNode

use of org.graalvm.compiler.nodes.LoopBeginNode in project graal by oracle.

the class LoopTransformations method fullUnroll.

public static void fullUnroll(LoopEx loop, PhaseContext context, CanonicalizerPhase canonicalizer) {
    // assert loop.isCounted(); //TODO (gd) strengthen : counted with known trip count
    LoopBeginNode loopBegin = loop.loopBegin();
    StructuredGraph graph = loopBegin.graph();
    int initialNodeCount = graph.getNodeCount();
    while (!loopBegin.isDeleted()) {
        Mark mark = graph.getMark();
        peel(loop);
        canonicalizer.applyIncremental(graph, context, mark);
        loop.invalidateFragments();
        if (graph.getNodeCount() > initialNodeCount + MaximumDesiredSize.getValue(graph.getOptions()) * 2) {
            throw new RetryableBailoutException("FullUnroll : Graph seems to grow out of proportion");
        }
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Mark(org.graalvm.compiler.graph.Graph.Mark)

Example 49 with LoopBeginNode

use of org.graalvm.compiler.nodes.LoopBeginNode in project graal by oracle.

the class LoopTransformations method processPreLoopPhis.

private static void processPreLoopPhis(LoopEx preLoop, LoopFragmentWhole mainLoop, LoopFragmentWhole postLoop) {
    // process phis for the post loop
    LoopBeginNode preLoopBegin = preLoop.loopBegin();
    for (PhiNode prePhiNode : preLoopBegin.phis()) {
        PhiNode postPhiNode = postLoop.getDuplicatedNode(prePhiNode);
        PhiNode mainPhiNode = mainLoop.getDuplicatedNode(prePhiNode);
        postPhiNode.setValueAt(0, mainPhiNode);
        // Build a work list to update the pre loop phis to the post loops phis
        for (Node usage : prePhiNode.usages().snapshot()) {
            if (usage == mainPhiNode) {
                continue;
            }
            if (preLoop.isOutsideLoop(usage)) {
                usage.replaceFirstInput(prePhiNode, postPhiNode);
            }
        }
    }
    for (Node node : preLoop.inside().nodes()) {
        for (Node externalUsage : node.usages().snapshot()) {
            if (preLoop.isOutsideLoop(externalUsage)) {
                Node postUsage = postLoop.getDuplicatedNode(node);
                assert postUsage != null;
                externalUsage.replaceFirstInput(node, postUsage);
            }
        }
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) SwitchNode(org.graalvm.compiler.nodes.extended.SwitchNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) IntegerLessThanNode(org.graalvm.compiler.nodes.calc.IntegerLessThanNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) SafepointNode(org.graalvm.compiler.nodes.SafepointNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode)

Example 50 with LoopBeginNode

use of org.graalvm.compiler.nodes.LoopBeginNode in project graal by oracle.

the class DefaultLoopPolicies method shouldPeel.

@Override
public boolean shouldPeel(LoopEx loop, ControlFlowGraph cfg, MetaAccessProvider metaAccess) {
    LoopBeginNode loopBegin = loop.loopBegin();
    double entryProbability = cfg.blockFor(loopBegin.forwardEnd()).probability();
    OptionValues options = cfg.graph.getOptions();
    if (entryProbability > MinimumPeelProbability.getValue(options) && loop.size() + loopBegin.graph().getNodeCount() < MaximumDesiredSize.getValue(options)) {
        // check whether we're allowed to peel this loop
        return loop.canDuplicateLoop();
    } else {
        return false;
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) OptionValues(org.graalvm.compiler.options.OptionValues)

Aggregations

LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)61 FixedNode (org.graalvm.compiler.nodes.FixedNode)30 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)26 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)24 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)23 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)22 Node (org.graalvm.compiler.graph.Node)21 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)21 EndNode (org.graalvm.compiler.nodes.EndNode)20 PhiNode (org.graalvm.compiler.nodes.PhiNode)20 ValueNode (org.graalvm.compiler.nodes.ValueNode)20 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)19 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)14 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)13 MergeNode (org.graalvm.compiler.nodes.MergeNode)11 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)10 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 ArrayList (java.util.ArrayList)9 IfNode (org.graalvm.compiler.nodes.IfNode)9 LogicNode (org.graalvm.compiler.nodes.LogicNode)9