setPhiType(s, t, phiDefTypes, j); dictionary.setOriginalRegister(r2.register, r1);
  private static void search (OPT_BasicBlock X, java.util.Stack[] S, OPT_IR ir,                               java.util.HashMap phiDefTypes,                               java.util.HashSet ambiguous) {    if (DEBUG)      System.out.println("SEARCH " + X);    OPT_SSADictionary dictionary = ir.HIRInfo.SSADictionary;    for (OPT_InstructionEnumeration ie =         X.forwardInstrEnumerator(); ie.hasMoreElements();) {      OPT_Instruction A = ie.next();      if (A.operator() != PHI) {        // replace each use        for (int u = A.getNumberOfDefs(); u < A.getNumberOfOperands(); u++) {          OPT_Operand op = A.getOperand(u);          if (op instanceof OPT_RegisterOperand) {            OPT_RegisterOperand rop = (OPT_RegisterOperand)op;            OPT_Register r1 = rop.register;            if (r1.isSSA())              continue;            if (r1.isPhysical())              continue;            OPT_RegisterOperand r2 = (OPT_RegisterOperand)                S[r1.getNumber()].peek();            if (DEBUG)              System.out.println("REPLACE NORMAL USE " + r1 + " with "                  + r2);            if (r2 != null) {              rop.register = r2.register;              OPT_DefUse.recordUse(rop);              dictionary.setOriginalRegister(r2.register, r1);            }          }        }      }      // replace each def      for (int d = 0; d < A.getNumberOfDefs(); d++) {        OPT_Operand op = A.getOperand(d);        if (op instanceof OPT_RegisterOperand) {          OPT_RegisterOperand rop = (OPT_RegisterOperand)op;          OPT_Register r1 = rop.register;          if (r1.isSSA())            continue;          if (r1.isPhysical())            continue;          OPT_Register r2 = ir.regpool.getReg(r1);          if (DEBUG)            System.out.println("PUSH " + r2 + " FOR " + r1 + "BECAUSE "                + A);          S[r1.getNumber()].push(new OPT_RegisterOperand(r2, rop.type));          // if we haven't yet determined the type of the def'ed          // register, (this can happen for phi defs occasionally)          // place this instruction in a set whose          // types are yet to be determined.          if (rop.type == null)            ambiguous.add(A);          rop.setRegister(r2);          r2.scratchObject = r1;          dictionary.setOriginalRegister(r2, r1);        }      }    } // end of first loop    if (DEBUG) System.out.println("SEARCH (second loop) " + X);    for (OPT_BasicBlockEnumeration y = X.getOut(); y.hasMoreElements();) {      OPT_BasicBlock Y = y.next();      if (Y.isExit())        continue;      OPT_Instruction s = Y.firstRealInstruction();      if (s == null)        continue;      int j = Y.whichPred(X);      // replace use USE in each PHI instruction      while (s.operator() == PHI) {        OPT_Operand valj = Phi.getValue(s, j);        if (valj instanceof OPT_RegisterOperand) {          // skip registers already marked SSA from a previous pass          if (!valj.asRegister().register.isSSA()) {            OPT_RegisterOperand rop = (OPT_RegisterOperand)valj;            OPT_Register r1 = rop.register;            OPT_RegisterOperand r2 = (OPT_RegisterOperand)                S[r1.getNumber()].peek();            if (r2 == null) {              // in this case, the register is never defined along              // this particular control flow path into the basic              // block.  So, null out the operand to indicate that              // that case will never happen.	      if (r1.isValidation()) {		Phi.setValue(s, j, new OPT_TrueGuardOperand());	      } else {		if (ir.IRStage == ir.LIR) {		  Phi.setValue(s, j, new OPT_IntConstantOperand(0));		} 		else {		  Phi.setValue(s, j, new OPT_NullConstantOperand());		}	      }            }             else {              rop.register = r2.register;              OPT_DefUse.recordUse(rop);              // if type is null, then this register was              // defined in a phi instruction.  get the type              // from the mapping phiDefTypes              VM_Type t = r2.type;              if (t == null) {                t = (VM_Type)phiDefTypes.get(r2.register);              }              // resolve the type for this phi instruction              setPhiType(s, t, phiDefTypes, j);              dictionary.setOriginalRegister(r2.register, r1);            }          }        }        s = s.nextInstructionInCodeOrder();      }    } // end of second loop    if (DEBUG) System.out.println("SEARCH (third loop) " + X);    for (Enumeration c = ir.HIRInfo.dominatorTree.getChildren(X);         c.hasMoreElements();) {      OPT_DominatorTreeNode v = (OPT_DominatorTreeNode)c.nextElement();      search(v.getBlock(), S, ir, phiDefTypes, ambiguous);    } // end of third loop    if (DEBUG) System.out.println("SEARCH (fourth loop) " + X);    for (OPT_InstructionEnumeration a = X.forwardInstrEnumerator();         a.hasMoreElements();) {      OPT_Instruction A = a.next();      // loop over each def      for (int d = 0; d < A.getNumberOfDefs(); d++) {        OPT_Operand newOp = A.getOperand(d);        if (newOp == null)          continue;        if (!newOp.isRegister())          continue;        OPT_Register newReg = newOp.asRegister().register;        if (newReg.isSSA())          continue;        if (newReg.isPhysical())          continue;        OPT_Register r1 = (OPT_Register)newReg.scratchObject;        S[r1.getNumber()].pop();        if (DEBUG)          System.out.println("POP " + r1);      }    } // end of fourth loop    if (DEBUG) System.out.println("FINISHED SEARCH " + X);  }