Search in sources :

Example 6 with InductionVariable

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

the class AMD64HotSpotAddressLowering method tryOptimize.

private static void tryOptimize(OffsetAddressNode offsetAddress, LoopEx loop) {
    EconomicMap<Node, InductionVariable> ivs = loop.getInductionVariables();
    InductionVariable currentIV = ivs.get(offsetAddress.getOffset());
    while (currentIV != null) {
        if (!(currentIV instanceof DerivedInductionVariable)) {
            break;
        }
        ValueNode currentValue = currentIV.valueNode();
        if (currentValue.isDeleted()) {
            break;
        }
        if (currentValue instanceof ZeroExtendNode) {
            ZeroExtendNode zeroExtendNode = (ZeroExtendNode) currentValue;
            if (applicableToImplicitZeroExtend(zeroExtendNode)) {
                ValueNode input = zeroExtendNode.getValue();
                if (input instanceof AddNode) {
                    AddNode add = (AddNode) input;
                    if (add.getX().isConstant()) {
                        optimizeAdd(zeroExtendNode, (ConstantNode) add.getX(), add.getY(), loop);
                    } else if (add.getY().isConstant()) {
                        optimizeAdd(zeroExtendNode, (ConstantNode) add.getY(), add.getX(), loop);
                    }
                }
            }
        }
        currentIV = ((DerivedInductionVariable) currentIV).getBase();
    }
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AMD64AddressNode(org.graalvm.compiler.core.amd64.AMD64AddressNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) CompressionNode(org.graalvm.compiler.nodes.CompressionNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) DerivedInductionVariable(org.graalvm.compiler.nodes.loop.DerivedInductionVariable) BasicInductionVariable(org.graalvm.compiler.nodes.loop.BasicInductionVariable) DerivedInductionVariable(org.graalvm.compiler.nodes.loop.DerivedInductionVariable) InductionVariable(org.graalvm.compiler.nodes.loop.InductionVariable) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Aggregations

InductionVariable (org.graalvm.compiler.nodes.loop.InductionVariable)6 ValueNode (org.graalvm.compiler.nodes.ValueNode)5 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)4 Node (org.graalvm.compiler.graph.Node)4 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)4 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)3 GuardNode (org.graalvm.compiler.nodes.GuardNode)3 GuardedValueNode (org.graalvm.compiler.nodes.GuardedValueNode)3 LogicNode (org.graalvm.compiler.nodes.LogicNode)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)3 MultiGuardNode (org.graalvm.compiler.nodes.extended.MultiGuardNode)3 BytecodePosition (jdk.vm.ci.code.BytecodePosition)2 SpeculationLog (jdk.vm.ci.meta.SpeculationLog)2 AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)2 CompressionNode (org.graalvm.compiler.nodes.CompressionNode)2 FrameState (org.graalvm.compiler.nodes.FrameState)2 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)2 PhiNode (org.graalvm.compiler.nodes.PhiNode)2 AddNode (org.graalvm.compiler.nodes.calc.AddNode)2