Search in sources :

Example 1 with DerivedInductionVariable

use of org.graalvm.compiler.loop.DerivedInductionVariable 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) GraalHotSpotVMConfigNode(org.graalvm.compiler.hotspot.nodes.GraalHotSpotVMConfigNode) 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.loop.DerivedInductionVariable) BasicInductionVariable(org.graalvm.compiler.loop.BasicInductionVariable) InductionVariable(org.graalvm.compiler.loop.InductionVariable) DerivedInductionVariable(org.graalvm.compiler.loop.DerivedInductionVariable) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Aggregations

AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)1 Node (org.graalvm.compiler.graph.Node)1 GraalHotSpotVMConfigNode (org.graalvm.compiler.hotspot.nodes.GraalHotSpotVMConfigNode)1 BasicInductionVariable (org.graalvm.compiler.loop.BasicInductionVariable)1 DerivedInductionVariable (org.graalvm.compiler.loop.DerivedInductionVariable)1 InductionVariable (org.graalvm.compiler.loop.InductionVariable)1 CompressionNode (org.graalvm.compiler.nodes.CompressionNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 PhiNode (org.graalvm.compiler.nodes.PhiNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 AddNode (org.graalvm.compiler.nodes.calc.AddNode)1 SignExtendNode (org.graalvm.compiler.nodes.calc.SignExtendNode)1 ZeroExtendNode (org.graalvm.compiler.nodes.calc.ZeroExtendNode)1 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)1 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)1