use of org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticNode in project graal by oracle.
the class IntegerExactFoldTest method testFolding.
@Test
public void testFolding() {
StructuredGraph graph = prepareGraph();
IntegerStamp a = StampFactory.forInteger(bits, lowerBoundA, upperBoundA);
IntegerStamp b = StampFactory.forInteger(bits, lowerBoundB, upperBoundB);
List<ParameterNode> params = graph.getNodes(ParameterNode.TYPE).snapshot();
params.get(0).replaceAtMatchingUsages(graph.addOrUnique(new PiNode(params.get(0), a)), x -> x instanceof IntegerExactArithmeticNode);
params.get(1).replaceAtMatchingUsages(graph.addOrUnique(new PiNode(params.get(1), b)), x -> x instanceof IntegerExactArithmeticNode);
Node originalNode = graph.getNodes().filter(x -> x instanceof IntegerExactArithmeticNode).first();
assertNotNull("original node must be in the graph", originalNode);
new CanonicalizerPhase().apply(graph, getDefaultHighTierContext());
ValueNode node = findNode(graph);
boolean overflowExpected = node instanceof IntegerExactArithmeticNode;
IntegerStamp resultStamp = (IntegerStamp) node.stamp(NodeView.DEFAULT);
operation.verifyOverflow(lowerBoundA, upperBoundA, lowerBoundB, upperBoundB, bits, overflowExpected, resultStamp);
}
use of org.graalvm.compiler.replacements.nodes.arithmetic.IntegerExactArithmeticNode 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);
}
Aggregations