public static boolean simplify(BasicBlock bb,IR ir){
  boolean didSomething=false;
  for (Enumeration<Instruction> branches=bb.enumerateBranchInstructions(); branches.hasMoreElements(); ) {
    Instruction s=branches.nextElement();
    if (Goto.conforms(s)) {
    }
 else     if (IfCmp.conforms(s)) {
      if (processIfCmp(ir,bb,s)) {
        branches=bb.enumerateBranchInstructions();
        bb.recomputeNormalOut(ir);
        didSomething=true;
      }
    }
 else     if (IfCmp2.conforms(s)) {
      if (processIfCmp2(ir,bb,s)) {
        branches=bb.enumerateBranchInstructions();
        bb.recomputeNormalOut(ir);
        didSomething=true;
      }
    }
 else     if (LookupSwitch.conforms(s)) {
      if (processLookupSwitch(ir,bb,s)) {
        branches=bb.enumerateBranchInstructions();
        bb.recomputeNormalOut(ir);
        didSomething=true;
      }
    }
 else     if (TableSwitch.conforms(s)) {
      if (processTableSwitch(ir,bb,s)) {
        branches=bb.enumerateBranchInstructions();
        bb.recomputeNormalOut(ir);
        didSomething=true;
      }
    }
 else     if (InlineGuard.conforms(s)) {
      if (processInlineGuard(ir,bb,s)) {
        branches=bb.enumerateBranchInstructions();
        bb.recomputeNormalOut(ir);
        didSomething=true;
      }
    }
  }
  return didSomething;
}

public static boolean simplify ( BasicBlock bb , IR ir ) { boolean didSomething = false ; for ( Enumeration < Instruction > branches = bb . enumerateBranchInstructions ( ) ; branches . hasMoreElements ( ) ; ) { Instruction s = branches . nextElement ( ) ; if ( Goto . conforms ( s ) ) { } else if ( IfCmp . conforms ( s ) ) { if ( processIfCmp ( ir , bb , s ) ) { branches = bb . enumerateBranchInstructions ( ) ; bb . recomputeNormalOut ( ir ) ; didSomething = true ; } } else if ( IfCmp2 . conforms ( s ) ) { if ( processIfCmp2 ( ir , bb , s ) ) { branches = bb . enumerateBranchInstructions ( ) ; bb . recomputeNormalOut ( ir ) ; didSomething = true ; } } else if ( LookupSwitch . conforms ( s ) ) { if ( processLookupSwitch ( ir , bb , s ) ) { branches = bb . enumerateBranchInstructions ( ) ; bb . recomputeNormalOut ( ir ) ; didSomething = true ; } } else if ( TableSwitch . conforms ( s ) ) { if ( processTableSwitch ( ir , bb , s ) ) { branches = bb . enumerateBranchInstructions ( ) ; bb . recomputeNormalOut ( ir ) ; didSomething = true ; } } else if ( InlineGuard . conforms ( s ) ) { if ( processInlineGuard ( ir , bb , s ) ) { branches = bb . enumerateBranchInstructions ( ) ; bb . recomputeNormalOut ( ir ) ; didSomething = true ; } } } return didSomething ; }
given a basic block , attempt to simplify any conditional branch instructions with constant operands . the instruction will be mutated in place . the control flow graph will be updated , but the caller is responsible for calling branchoptmizations after simplify has been called on all basic blocks in the ir to remove unreachable code .
