return generateBranchingTypeCheck(s, ir, ref, LHStype, RHStib,
return generateBranchingTypeCheck(s, ir, ref.copy(), LHStype, RHStib,
  static OPT_Instruction instanceOf(OPT_Instruction s, OPT_IR ir) {    OPT_RegisterOperand result = InstanceOf.getClearResult(s);    VM_TypeReference LHStype = InstanceOf.getType(s).getTypeRef();    OPT_Operand ref = InstanceOf.getClearRef(s);    OPT_Instruction next = s.nextInstructionInCodeOrder();    if (next.operator() == INT_IFCMP &&         IfCmp.getVal1(next) instanceof OPT_RegisterOperand &&         result.similar(IfCmp.getVal1(next))) {      // The result of instanceof is being consumed by a conditional branch.      // Optimize this case by generating a branching type check       // instead of producing a value.      // TODO: This is really not safe: suppose the if is NOT the       // only use of the result of the instanceof.        // The way to fix this is to add ifInstanceOf and ifNotInstanceOf      // operators to the IR and have OPT_Simple transform       // instanceof, intIfCmp based on the U/D chains.      // See defect 2114.      OPT_Operand val2 = IfCmp.getVal2(next);      if (VM.VerifyAssertions) VM._assert(val2.isIntConstant());      int ival2 = ((OPT_IntConstantOperand)val2).value;      OPT_ConditionOperand cond = IfCmp.getCond(next);      boolean branchCondition =         (((ival2 == 0) && (cond.isNOT_EQUAL() || cond.isLESS_EQUAL())) ||         ((ival2 == 1) && (cond.isEQUAL() || cond.isGREATER_EQUAL())));      OPT_BasicBlock branchBB = next.getBranchTarget();      OPT_RegisterOperand oldGuard = IfCmp.getGuardResult(next);      next.remove();      OPT_BasicBlock fallThroughBB = fallThroughBB(s, ir);      OPT_BasicBlock falseBranch =         branchCondition ? fallThroughBB : branchBB;      OPT_BasicBlock trueBranch =         branchCondition ? branchBB : fallThroughBB;      OPT_BranchProfileOperand bp = IfCmp.getClearBranchProfile(next);      if (branchCondition) bp = bp.flip();      OPT_Instruction nullComp =         IfCmp.create(REF_IFCMP, oldGuard.copyRO(), ref.copy(),                      new OPT_NullConstantOperand(),                     OPT_ConditionOperand.EQUAL(),                      falseBranch.makeJumpTarget(),                     OPT_BranchProfileOperand.unlikely());      s.insertBefore(nullComp);      OPT_BasicBlock myBlock = s.getBasicBlock();      OPT_BasicBlock instanceOfBlock = myBlock.splitNodeAt(nullComp, ir);      myBlock.insertOut(instanceOfBlock);      myBlock.insertOut(falseBranch);      ir.cfg.linkInCodeOrder(myBlock, instanceOfBlock);      OPT_RegisterOperand RHStib = getTIB(s, ir, ref, oldGuard.copyRO());      return generateBranchingTypeCheck(s, ir, ref, LHStype, RHStib,                                         trueBranch, falseBranch, oldGuard, bp);    } else {      // Not a branching pattern      OPT_RegisterOperand guard = ir.regpool.makeTempValidation();      OPT_BasicBlock instanceOfBlock =         s.getBasicBlock().segregateInstruction(s, ir);      OPT_BasicBlock prevBB = instanceOfBlock.prevBasicBlockInCodeOrder();      OPT_BasicBlock nextBB = instanceOfBlock.nextBasicBlockInCodeOrder();      OPT_BasicBlock nullCaseBB =         instanceOfBlock.createSubBlock(s.bcIndex, ir, .01f);      prevBB.appendInstruction(IfCmp.create(REF_IFCMP, guard,                                             ref.copy(),                                             new OPT_NullConstantOperand(),                                            OPT_ConditionOperand.EQUAL(),                                             nullCaseBB.makeJumpTarget(),                                            OPT_BranchProfileOperand.unlikely()));      nullCaseBB.appendInstruction(Move.create(INT_MOVE, result.copyD2D(), IC(0)));      nullCaseBB.appendInstruction(Goto.create(GOTO, nextBB.makeJumpTarget()));      // Stitch together the CFG; add nullCaseBB to the end of code array.      prevBB.insertOut(nullCaseBB);      nullCaseBB.insertOut(nextBB);      ir.cfg.addLastInCodeOrder(nullCaseBB);      OPT_RegisterOperand RHStib = getTIB(s, ir, ref, guard.copyD2U());      return generateValueProducingTypeCheck(s, ir, ref, LHStype, RHStib,                                              result);    }  }