private ValueNode op(ValueNode b, ValueNode o) { if (value instanceof AddNode) { return add(graph(), b, o); } if (value instanceof SubNode) { if (base.valueNode() == value.getX()) { return sub(graph(), b, o); } else { assert base.valueNode() == value.getY(); return sub(graph(), o, b); } } throw JVMCIError.shouldNotReachHere(); }
private long op(long b, long o) { if (value instanceof AddNode) { return b + o; } if (value instanceof SubNode) { if (base.valueNode() == value.getX()) { return b - o; } else { assert base.valueNode() == value.getY(); return o - b; } } throw JVMCIError.shouldNotReachHere(); }
@Override public ValueNode strideNode() { if (value instanceof SubNode && base.valueNode() == value.getY()) { return graph().unique(new NegateNode(base.strideNode())); } return base.strideNode(); }
@Override public long constantStride() { if (value instanceof SubNode && base.valueNode() == value.getY()) { return -base.constantStride(); } return base.constantStride(); }
@Test public void testValueProxyInputs() { StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES); for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) { fs.replaceAtUsages(null); GraphUtil.killWithUnusedFloatingInputs(fs); } SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.LATEST); schedulePhase.apply(graph); ScheduleResult schedule = graph.getLastSchedule(); NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock(); assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1); LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first(); List<Node> list = schedule.nodesFor(nodeToBlock.get(loopExit)); for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) { if (!(node instanceof AddNode)) { assertTrue(node.toString(), nodeToBlock.get(node) == nodeToBlock.get(loopExit)); assertTrue( list.indexOf(node) + " < " + list.indexOf(loopExit) + ", " + node + ", " + loopExit, list.indexOf(node) < list.indexOf(loopExit)); } } }
@Override public String toString() { return String.format( "DerivedOffsetInductionVariable base (%s) %s %s", base, value.getNodeClass().shortName(), offset); }