Exemplo n.º 1
0
 public static void checkRedundantProxy(ProxyNode vpn) {
   AbstractBeginNode proxyPoint = vpn.proxyPoint();
   if (proxyPoint instanceof LoopExitNode) {
     LoopExitNode exit = (LoopExitNode) proxyPoint;
     LoopBeginNode loopBegin = exit.loopBegin();
     ValueNode vpnValue = vpn.value();
     for (ValueNode v : loopBegin.stateAfter().values()) {
       ValueNode v2 = v;
       if (loopBegin.isPhiAtMerge(v2)) {
         v2 = ((PhiNode) v2).valueAt(loopBegin.forwardEnd());
       }
       if (vpnValue == v2) {
         Collection<PhiNode> phiUsages = vpn.usages().filter(PhiNode.class).snapshot();
         Collection<ProxyNode> proxyUsages = vpn.usages().filter(ProxyNode.class).snapshot();
         vpn.graph().replaceFloating(vpn, vpnValue);
         for (PhiNode phi : phiUsages) {
           checkRedundantPhi(phi);
         }
         for (ProxyNode proxy : proxyUsages) {
           checkRedundantProxy(proxy);
         }
         return;
       }
     }
   }
 }
Exemplo n.º 2
0
 public static void normalizeLoopBegin(LoopBeginNode begin) {
   // Delete unnecessary loop phi functions, i.e., phi functions where all inputs are either
   // the same or the phi itself.
   for (PhiNode phi : begin.phis().snapshot()) {
     GraphUtil.checkRedundantPhi(phi);
   }
   for (LoopExitNode exit : begin.loopExits()) {
     for (ProxyNode vpn : exit.proxies().snapshot()) {
       GraphUtil.checkRedundantProxy(vpn);
     }
   }
 }
Exemplo n.º 3
0
  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);
      }
    }
  }