Search in sources :

Example 1 with IntegerExactArithmeticSplitNode

use of org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticSplitNode in project graal by oracle.

the class IntegerExactFoldTest method testFoldingAfterLowering.

@Test
public void testFoldingAfterLowering() {
    StructuredGraph graph = prepareGraph();
    Node originalNode = graph.getNodes().filter(x -> x instanceof IntegerExactArithmeticNode).first();
    assertNotNull("original node must be in the graph", originalNode);
    graph.setGuardsStage(GuardsStage.FIXED_DEOPTS);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    PhaseContext context = new PhaseContext(getProviders());
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    IntegerExactArithmeticSplitNode loweredNode = graph.getNodes().filter(IntegerExactArithmeticSplitNode.class).first();
    assertNotNull("the lowered node must be in the graph", loweredNode);
    loweredNode.getX().setStamp(StampFactory.forInteger(bits, lowerBoundA, upperBoundA));
    loweredNode.getY().setStamp(StampFactory.forInteger(bits, lowerBoundB, upperBoundB));
    new CanonicalizerPhase().apply(graph, context);
    ValueNode node = findNode(graph);
    boolean overflowExpected = node instanceof IntegerExactArithmeticSplitNode;
    IntegerStamp resultStamp = (IntegerStamp) node.stamp(NodeView.DEFAULT);
    operation.verifyOverflow(lowerBoundA, upperBoundA, lowerBoundB, upperBoundB, bits, overflowExpected, resultStamp);
}
Also used : GuardsStage(org.graalvm.compiler.nodes.StructuredGraph.GuardsStage) LoweringTool(org.graalvm.compiler.nodes.spi.LoweringTool) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) AllowAssumptions(org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions) ArrayList(java.util.ArrayList) IntegerExactArithmeticNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticNode) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) StampFactory(org.graalvm.compiler.core.common.type.StampFactory) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) Parameterized(org.junit.runners.Parameterized) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) IntegerExactArithmeticSplitNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticSplitNode) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) NodeView(org.graalvm.compiler.nodes.NodeView) Test(org.junit.Test) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) List(java.util.List) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Node(org.graalvm.compiler.graph.Node) Assert(org.junit.Assert) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) IntegerExactArithmeticNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) IntegerExactArithmeticSplitNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticSplitNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) ValueNode(org.graalvm.compiler.nodes.ValueNode) IntegerExactArithmeticNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) IntegerExactArithmeticSplitNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticSplitNode) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)1 StampFactory (org.graalvm.compiler.core.common.type.StampFactory)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1 Node (org.graalvm.compiler.graph.Node)1 NodeView (org.graalvm.compiler.nodes.NodeView)1 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)1 PiNode (org.graalvm.compiler.nodes.PiNode)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 AllowAssumptions (org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions)1 GuardsStage (org.graalvm.compiler.nodes.StructuredGraph.GuardsStage)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 LoweringTool (org.graalvm.compiler.nodes.spi.LoweringTool)1 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)1 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)1