float weight = defaultProb.takenProbability >= 1f ? 0f : 1f / (1f - defaultProb.takenProbability);
final boolean defaultIsAlways = defaultProb.takenProbability >= 1f; final float weight = defaultIsAlways ? 1f / number : 1f / (1f - defaultProb.takenProbability);
  static OPT_Instruction tableswitch (OPT_Instruction s, OPT_IR ir) {        OPT_Instruction s2;    int lowLimit = TableSwitch.getLow(s).value;    int highLimit = TableSwitch.getHigh(s).value;    int number = highLimit - lowLimit + 1;    if (VM.VerifyAssertions)      VM._assert(number > 0);    // also checks that there are < 2^31 targets    OPT_Operand val = TableSwitch.getClearValue(s);    OPT_BranchOperand defaultLabel = TableSwitch.getClearDefault(s);    if (number < 8) {           // convert into a lookupswitch      OPT_Instruction l = LookupSwitch.create(LOOKUPSWITCH, val, null,                                               null, defaultLabel,                                               TableSwitch.getClearDefaultBranchProfile(s),                                              number*3);      for (int i = 0; i < number; i++) {        LookupSwitch.setMatch(l, i, IC(lowLimit + i));        LookupSwitch.setTarget(l, i, TableSwitch.getClearTarget(s, i));        LookupSwitch.setBranchProfile(l, i,                                       TableSwitch.getClearBranchProfile(s,i));      }      s.insertFront(l);      return s.remove();    }    OPT_RegisterOperand reg = val.asRegister();    OPT_BasicBlock BB1 = s.getBasicBlock();    OPT_BasicBlock BB2 = BB1.splitNodeAt(s, ir);    OPT_BasicBlock defaultBB = defaultLabel.target.getBasicBlock();    /******* First basic block */    OPT_RegisterOperand t;    if (lowLimit != 0) {      t = InsertBinary(s, ir, INT_ADD, VM_TypeReference.Int, reg, IC(-lowLimit));    } else {      t = reg.copyU2U();    }    OPT_BranchProfileOperand defaultProb = TableSwitch.getClearDefaultBranchProfile(s);    s.replace(IfCmp.create(INT_IFCMP, null, t, IC(highLimit - lowLimit),                           OPT_ConditionOperand.HIGHER(),                            defaultLabel, defaultProb));    float weight = defaultProb.takenProbability >= 1f ?      0f : 1f / (1f - defaultProb.takenProbability);    /********** second Basic Block ******/    s2 = LowTableSwitch.create(LOWTABLESWITCH, t.copyRO(), number*2);    boolean containsDefault = false;    for (int i = 0; i < number; i++) {      OPT_BranchOperand b = TableSwitch.getClearTarget(s, i);      LowTableSwitch.setTarget(s2, i, b);      OPT_BranchProfileOperand bp = TableSwitch.getClearBranchProfile(s,i);      bp.takenProbability *= weight;      LowTableSwitch.setBranchProfile(s2, i, bp);      if (b.target == defaultLabel.target)        containsDefault = true;    }    // Fixup the CFG and code order.    BB1.insertOut(BB2);    BB1.insertOut(defaultBB);    ir.cfg.linkInCodeOrder(BB1, BB2);    if (!containsDefault)      BB2.deleteOut(defaultBB);    // Simplify a fringe case...    // if all targets of the LOWTABLESWITCH are the same,    // then just use a GOTO instead of the LOWTABLESWITCH.    // This actually happens (very occasionally), and is easy to test for.    if (BB2.getNumberOfNormalOut() == 1) {      BB2.appendInstruction(Goto.create(GOTO,                                         LowTableSwitch.getTarget(s2, 0)));    } else {      BB2.appendInstruction(s2);    }    // continue at next BB    s = BB2.lastInstruction();    return s;  }