コード例 #1
0
 public void reduceTrivialMerge(AbstractMergeNode merge) {
   assert merge.forwardEndCount() == 1;
   assert !(merge instanceof LoopBeginNode) || ((LoopBeginNode) merge).loopEnds().isEmpty();
   for (PhiNode phi : merge.phis().snapshot()) {
     assert phi.valueCount() == 1;
     ValueNode singleValue = phi.valueAt(0);
     phi.replaceAtUsagesAndDelete(singleValue);
   }
   // remove loop exits
   if (merge instanceof LoopBeginNode) {
     ((LoopBeginNode) merge).removeExits();
   }
   AbstractEndNode singleEnd = merge.forwardEndAt(0);
   FixedNode sux = merge.next();
   FrameState stateAfter = merge.stateAfter();
   // evacuateGuards
   merge.prepareDelete((FixedNode) singleEnd.predecessor());
   merge.safeDelete();
   if (stateAfter != null && stateAfter.isAlive() && stateAfter.hasNoUsages()) {
     GraphUtil.killWithUnusedFloatingInputs(stateAfter);
   }
   if (sux == null) {
     singleEnd.replaceAtPredecessor(null);
     singleEnd.safeDelete();
   } else {
     singleEnd.replaceAndDelete(sux);
   }
 }
コード例 #2
0
ファイル: GraphUtil.java プロジェクト: rjsingh/graal
  public static void checkRedundantPhi(PhiNode phiNode) {
    if (phiNode.isDeleted() || phiNode.valueCount() == 1) {
      return;
    }

    ValueNode singleValue = phiNode.singleValue();
    if (singleValue != null) {
      Collection<PhiNode> phiUsages = phiNode.usages().filter(PhiNode.class).snapshot();
      Collection<ProxyNode> proxyUsages = phiNode.usages().filter(ProxyNode.class).snapshot();
      phiNode.graph().replaceFloating(phiNode, singleValue);
      for (PhiNode phi : phiUsages) {
        checkRedundantPhi(phi);
      }
      for (ProxyNode proxy : proxyUsages) {
        checkRedundantProxy(proxy);
      }
    }
  }