Program: 149814
Project: 149814
Buggy source:
/** 
 * Perform Local Constant propagation for a method.
 * @param ir the IR to optimize
 */
public void perform(IR ir){
  HashMap<Register,ConstantOperand> info=new HashMap<Register,ConstantOperand>();
  boolean runBranchOpts=false;
  for (BasicBlock bb=ir.firstBasicBlockInCodeOrder(); bb != null; bb=bb.nextBasicBlockInCodeOrder()) {
    if (bb.isEmpty())     continue;
    container.counter2++;
    if (bb.getInfrequent()) {
      container.counter1++;
      if (ir.options.FREQ_FOCUS_EFFORT)       continue;
    }
    for (Instruction s=bb.firstRealInstruction(), next, sentinel=bb.lastInstruction(); s != sentinel; s=next) {
      next=s.nextInstructionInCodeOrder();
      if (!info.isEmpty()) {
        int numUses=s.getNumberOfUses();
        if (numUses > 0) {
          boolean didSomething=false;
          int numDefs=s.getNumberOfDefs();
          for (int idx=numDefs; idx < numUses + numDefs; idx++) {
            Operand use=s.getOperand(idx);
            if (use instanceof RegisterOperand) {
              RegisterOperand rUse=(RegisterOperand)use;
              Operand value=info.get(rUse.getRegister());
              if (value != null) {
                didSomething=true;
                s.putOperand(idx,value.copy());
              }
            }
          }
          if (didSomething)           Simplifier.simplify(ir.IRStage == IR.HIR,ir.regpool,s);
        }
        for (OperandEnumeration e=s.getDefs(); e.hasMoreElements(); ) {
          Operand def=e.next();
          if (def != null) {
            Register defReg=((RegisterOperand)def).getRegister();
            ConstantOperand cOp=info.get(defReg);
            if (cOp != null) {
              if (Move.conforms(s) && Move.getVal(s).isConstant()) {
                ConstantOperand cOp2=(ConstantOperand)Move.getVal(s);
                if (cOp2.similar(cOp)) {
                  s.remove();
                }
 else {
                  info.put(defReg,cOp2);
                }
              }
 else {
                info.remove(defReg);
              }
            }
          }
        }
      }
 else       if (Move.conforms(s) && Move.getVal(s).isConstant()) {
        info.put(Move.getResult(s).getRegister(),(ConstantOperand)Move.getVal(s));
      }
    }
    info.clear();
    runBranchOpts|=BranchSimplifier.simplify(bb,ir);
  }
  if (runBranchOpts) {
    new BranchOptimizations(0,true,false,false).perform(ir);
  }
}

Fixed version (ground truth):
/** 
 * Perform Local Constant propagation for a method.
 * @param ir the IR to optimize
 */
public void perform(IR ir){
  HashMap<Register,ConstantOperand> info=new HashMap<Register,ConstantOperand>();
  boolean runBranchOpts=false;
  for (BasicBlock bb=ir.firstBasicBlockInCodeOrder(); bb != null; bb=bb.nextBasicBlockInCodeOrder()) {
    if (bb.isEmpty())     continue;
    container.counter2++;
    if (bb.getInfrequent()) {
      container.counter1++;
      if (ir.options.FREQ_FOCUS_EFFORT)       continue;
    }
    for (Instruction s=bb.firstRealInstruction(), next, sentinel=bb.lastInstruction(); s != sentinel; s=next) {
      next=s.nextInstructionInCodeOrder();
      if (!info.isEmpty()) {
        int numUses=s.getNumberOfPureUses();
        if (numUses > 0) {
          boolean didSomething=false;
          int numDefs=s.getNumberOfDefs();
          for (int idx=numDefs; idx < numUses + numDefs; idx++) {
            Operand use=s.getOperand(idx);
            if (use instanceof RegisterOperand) {
              RegisterOperand rUse=(RegisterOperand)use;
              Operand value=info.get(rUse.getRegister());
              if (value != null) {
                didSomething=true;
                s.putOperand(idx,value.copy());
              }
            }
          }
          if (didSomething) {
            Simplifier.simplify(ir.IRStage == IR.HIR,ir.regpool,s);
          }
        }
        if (!info.isEmpty()) {
          for (OperandEnumeration e=s.getDefs(); e.hasMoreElements(); ) {
            Operand def=e.next();
            if (def != null) {
              Register defReg=((RegisterOperand)def).getRegister();
              info.remove(defReg);
            }
          }
        }
      }
      if (Move.conforms(s) && Move.getVal(s).isConstant()) {
        info.put(Move.getResult(s).getRegister(),(ConstantOperand)Move.getVal(s));
      }
    }
    info.clear();
    runBranchOpts|=BranchSimplifier.simplify(bb,ir);
  }
  if (runBranchOpts) {
    new BranchOptimizations(0,true,false,false).perform(ir);
  }
}