Program: 149812
Project: 149812
Buggy source:
/** 
 * Given an instruction, attempt to simplify it. The instruction will be mutated in place. <p> We don't deal with branching operations here -- doing peephole optimizations of branches is the job of a separate module.
 * @param HIR is this the HIR phase?
 * @param regpool register pool in case simplification requires a temporary register
 * @param s the instruction to simplify
 * @return one of UNCHANGED, MOVE_FOLDED, MOVE_REDUCED, TRAP_REDUCED, REDUCED
 */
public static DefUseEffect simplify(boolean hir,AbstractRegisterPool regpool,Instruction s){
  DefUseEffect result;
  char opcode=s.getOpcode();
switch (opcode) {
case GUARD_COMBINE_opcode:
    result=guardCombine(s);
  break;
case TRAP_IF_opcode:
result=trapIf(s);
break;
case NULL_CHECK_opcode:
result=nullCheck(s);
break;
case INT_ZERO_CHECK_opcode:
result=intZeroCheck(s);
break;
case LONG_ZERO_CHECK_opcode:
result=longZeroCheck(s);
break;
case CHECKCAST_opcode:
result=checkcast(s);
break;
case CHECKCAST_UNRESOLVED_opcode:
result=checkcast(s);
break;
case CHECKCAST_NOTNULL_opcode:
result=checkcastNotNull(s);
break;
case INSTANCEOF_opcode:
result=instanceOf(s);
break;
case INSTANCEOF_NOTNULL_opcode:
result=instanceOfNotNull(s);
break;
case OBJARRAY_STORE_CHECK_opcode:
result=objarrayStoreCheck(s);
break;
case OBJARRAY_STORE_CHECK_NOTNULL_opcode:
result=objarrayStoreCheckNotNull(s);
break;
case MUST_IMPLEMENT_INTERFACE_opcode:
result=mustImplementInterface(s);
break;
case INT_COND_MOVE_opcode:
result=intCondMove(s);
break;
case LONG_COND_MOVE_opcode:
result=longCondMove(s);
break;
case FLOAT_COND_MOVE_opcode:
result=floatCondMove(s);
break;
case DOUBLE_COND_MOVE_opcode:
result=doubleCondMove(s);
break;
case REF_COND_MOVE_opcode:
result=refCondMove(s);
break;
case GUARD_COND_MOVE_opcode:
result=guardCondMove(s);
break;
case BOOLEAN_NOT_opcode:
result=booleanNot(s);
break;
case BOOLEAN_CMP_INT_opcode:
result=booleanCmpInt(s);
break;
case BOOLEAN_CMP_ADDR_opcode:
result=booleanCmpAddr(s);
break;
case INT_ADD_opcode:
result=intAdd(s);
break;
case INT_AND_opcode:
result=intAnd(s);
break;
case INT_DIV_opcode:
result=intDiv(s);
break;
case INT_MUL_opcode:
result=intMul(regpool,s);
break;
case INT_NEG_opcode:
result=intNeg(s);
break;
case INT_NOT_opcode:
result=intNot(s);
break;
case INT_OR_opcode:
result=intOr(s);
break;
case INT_REM_opcode:
result=intRem(s);
break;
case INT_SHL_opcode:
result=intShl(s);
break;
case INT_SHR_opcode:
result=intShr(s);
break;
case INT_SUB_opcode:
result=intSub(s);
break;
case INT_USHR_opcode:
result=intUshr(s);
break;
case INT_XOR_opcode:
result=intXor(s);
break;
case REF_ADD_opcode:
result=refAdd(s);
break;
case REF_AND_opcode:
result=refAnd(s);
break;
case REF_SHL_opcode:
result=refShl(s);
break;
case REF_SHR_opcode:
result=refShr(s);
break;
case REF_NEG_opcode:
result=refNeg(s);
break;
case REF_NOT_opcode:
result=refNot(s);
break;
case REF_OR_opcode:
result=refOr(s);
break;
case REF_SUB_opcode:
result=refSub(s);
break;
case REF_USHR_opcode:
result=refUshr(s);
break;
case REF_XOR_opcode:
result=refXor(s);
break;
case LONG_ADD_opcode:
result=longAdd(s);
break;
case LONG_AND_opcode:
result=longAnd(s);
break;
case LONG_CMP_opcode:
result=longCmp(s);
break;
case LONG_DIV_opcode:
result=longDiv(s);
break;
case LONG_MUL_opcode:
result=longMul(regpool,s);
break;
case LONG_NEG_opcode:
result=longNeg(s);
break;
case LONG_NOT_opcode:
result=longNot(s);
break;
case LONG_OR_opcode:
result=longOr(s);
break;
case LONG_REM_opcode:
result=longRem(s);
break;
case LONG_SHL_opcode:
result=longShl(s);
break;
case LONG_SHR_opcode:
result=longShr(s);
break;
case LONG_SUB_opcode:
result=longSub(s);
break;
case LONG_USHR_opcode:
result=longUshr(s);
break;
case LONG_XOR_opcode:
result=longXor(s);
break;
case FLOAT_ADD_opcode:
result=floatAdd(s);
break;
case FLOAT_CMPG_opcode:
result=floatCmpg(s);
break;
case FLOAT_CMPL_opcode:
result=floatCmpl(s);
break;
case FLOAT_DIV_opcode:
result=floatDiv(s);
break;
case FLOAT_MUL_opcode:
result=floatMul(s);
break;
case FLOAT_NEG_opcode:
result=floatNeg(s);
break;
case FLOAT_REM_opcode:
result=floatRem(s);
break;
case FLOAT_SUB_opcode:
result=floatSub(s);
break;
case FLOAT_SQRT_opcode:
result=floatSqrt(s);
break;
case DOUBLE_ADD_opcode:
result=doubleAdd(s);
break;
case DOUBLE_CMPG_opcode:
result=doubleCmpg(s);
break;
case DOUBLE_CMPL_opcode:
result=doubleCmpl(s);
break;
case DOUBLE_DIV_opcode:
result=doubleDiv(s);
break;
case DOUBLE_MUL_opcode:
result=doubleMul(s);
break;
case DOUBLE_NEG_opcode:
result=doubleNeg(s);
break;
case DOUBLE_REM_opcode:
result=doubleRem(s);
break;
case DOUBLE_SUB_opcode:
result=doubleSub(s);
break;
case DOUBLE_SQRT_opcode:
result=doubleSqrt(s);
break;
case DOUBLE_2FLOAT_opcode:
result=double2Float(s);
break;
case DOUBLE_2INT_opcode:
result=double2Int(s);
break;
case DOUBLE_2LONG_opcode:
result=double2Long(s);
break;
case DOUBLE_AS_LONG_BITS_opcode:
result=doubleAsLongBits(s);
break;
case INT_2DOUBLE_opcode:
result=int2Double(s);
break;
case INT_2BYTE_opcode:
result=int2Byte(s);
break;
case INT_2USHORT_opcode:
result=int2UShort(s);
break;
case INT_2FLOAT_opcode:
result=int2Float(s);
break;
case INT_2LONG_opcode:
result=int2Long(s);
break;
case INT_2ADDRSigExt_opcode:
result=int2AddrSigExt(s);
break;
case INT_2ADDRZerExt_opcode:
result=int2AddrZerExt(s);
break;
case LONG_2ADDR_opcode:
result=long2Addr(s);
break;
case INT_2SHORT_opcode:
result=int2Short(s);
break;
case INT_BITS_AS_FLOAT_opcode:
result=intBitsAsFloat(s);
break;
case ADDR_2INT_opcode:
result=addr2Int(s);
break;
case ADDR_2LONG_opcode:
result=addr2Long(s);
break;
case FLOAT_2DOUBLE_opcode:
result=float2Double(s);
break;
case FLOAT_2INT_opcode:
result=float2Int(s);
break;
case FLOAT_2LONG_opcode:
result=float2Long(s);
break;
case FLOAT_AS_INT_BITS_opcode:
result=floatAsIntBits(s);
break;
case LONG_2FLOAT_opcode:
result=long2Float(s);
break;
case LONG_2INT_opcode:
result=long2Int(s);
break;
case LONG_2DOUBLE_opcode:
result=long2Double(s);
break;
case LONG_BITS_AS_DOUBLE_opcode:
result=longBitsAsDouble(s);
break;
case ARRAYLENGTH_opcode:
result=arrayLength(s);
break;
case BOUNDS_CHECK_opcode:
result=boundsCheck(s);
break;
case CALL_opcode:
result=call(hir,regpool,s);
break;
case GETFIELD_opcode:
result=getField(s);
break;
case GET_OBJ_TIB_opcode:
result=getObjTib(s);
break;
case GET_CLASS_TIB_opcode:
result=getClassTib(s);
break;
case GET_TYPE_FROM_TIB_opcode:
result=getTypeFromTib(s);
break;
case GET_ARRAY_ELEMENT_TIB_FROM_TIB_opcode:
result=getArrayElementTibFromTib(s);
break;
case GET_SUPERCLASS_IDS_FROM_TIB_opcode:
result=getSuperclassIdsFromTib(s);
break;
case GET_DOES_IMPLEMENT_FROM_TIB_opcode:
result=getDoesImplementFromTib(s);
break;
case REF_LOAD_opcode:
result=refLoad(s);
break;
default :
result=DefUseEffect.UNCHANGED;
}
if (VM.VerifyAssertions) {
switch (result) {
case MOVE_FOLDED:
VM._assert(Move.conforms(s) && (Move.getVal(s) instanceof ConstantOperand),"String_Node_Str" + s + "String_Node_Str"+ OperatorNames.operatorName[opcode]);
break;
case MOVE_REDUCED:
VM._assert(Move.conforms(s) && !(Move.getVal(s) instanceof ConstantOperand),"String_Node_Str" + s + "String_Node_Str"+ OperatorNames.operatorName[opcode]);
break;
default :
}
}
return result;
}

Fixed version (ground truth):
/** 
 * Given an instruction, attempt to simplify it. The instruction will be mutated in place. <p> We don't deal with branching operations here -- doing peephole optimizations of branches is the job of a separate module.
 * @param HIR is this the HIR phase?
 * @param regpool register pool in case simplification requires a temporary register
 * @param s the instruction to simplify
 * @return one of UNCHANGED, MOVE_FOLDED, MOVE_REDUCED, TRAP_REDUCED, REDUCED
 */
public static DefUseEffect simplify(boolean hir,AbstractRegisterPool regpool,Instruction s){
  DefUseEffect result;
  char opcode=s.getOpcode();
switch (opcode) {
case GUARD_COMBINE_opcode:
    result=guardCombine(s);
  break;
case TRAP_IF_opcode:
result=trapIf(s);
break;
case NULL_CHECK_opcode:
result=nullCheck(s);
break;
case INT_ZERO_CHECK_opcode:
result=intZeroCheck(s);
break;
case LONG_ZERO_CHECK_opcode:
result=longZeroCheck(s);
break;
case CHECKCAST_opcode:
result=checkcast(s);
break;
case CHECKCAST_UNRESOLVED_opcode:
result=checkcast(s);
break;
case CHECKCAST_NOTNULL_opcode:
result=checkcastNotNull(s);
break;
case INSTANCEOF_opcode:
result=instanceOf(s);
break;
case INSTANCEOF_NOTNULL_opcode:
result=instanceOfNotNull(s);
break;
case OBJARRAY_STORE_CHECK_opcode:
result=objarrayStoreCheck(s);
break;
case OBJARRAY_STORE_CHECK_NOTNULL_opcode:
result=objarrayStoreCheckNotNull(s);
break;
case MUST_IMPLEMENT_INTERFACE_opcode:
result=mustImplementInterface(s);
break;
case INT_COND_MOVE_opcode:
result=intCondMove(s);
break;
case LONG_COND_MOVE_opcode:
result=longCondMove(s);
break;
case FLOAT_COND_MOVE_opcode:
result=floatCondMove(s);
break;
case DOUBLE_COND_MOVE_opcode:
result=doubleCondMove(s);
break;
case REF_COND_MOVE_opcode:
result=refCondMove(s);
break;
case GUARD_COND_MOVE_opcode:
result=guardCondMove(s);
break;
case BOOLEAN_NOT_opcode:
result=booleanNot(s);
break;
case BOOLEAN_CMP_INT_opcode:
result=booleanCmpInt(s);
break;
case BOOLEAN_CMP_ADDR_opcode:
result=booleanCmpAddr(s);
break;
case INT_ADD_opcode:
result=intAdd(s);
break;
case INT_AND_opcode:
result=intAnd(s);
break;
case INT_DIV_opcode:
result=intDiv(regpool,s);
break;
case INT_MUL_opcode:
result=intMul(regpool,s);
break;
case INT_NEG_opcode:
result=intNeg(s);
break;
case INT_NOT_opcode:
result=intNot(s);
break;
case INT_OR_opcode:
result=intOr(s);
break;
case INT_REM_opcode:
result=intRem(s);
break;
case INT_SHL_opcode:
result=intShl(s);
break;
case INT_SHR_opcode:
result=intShr(s);
break;
case INT_SUB_opcode:
result=intSub(s);
break;
case INT_USHR_opcode:
result=intUshr(s);
break;
case INT_XOR_opcode:
result=intXor(s);
break;
case REF_ADD_opcode:
result=refAdd(s);
break;
case REF_AND_opcode:
result=refAnd(s);
break;
case REF_SHL_opcode:
result=refShl(s);
break;
case REF_SHR_opcode:
result=refShr(s);
break;
case REF_NEG_opcode:
result=refNeg(s);
break;
case REF_NOT_opcode:
result=refNot(s);
break;
case REF_OR_opcode:
result=refOr(s);
break;
case REF_SUB_opcode:
result=refSub(s);
break;
case REF_USHR_opcode:
result=refUshr(s);
break;
case REF_XOR_opcode:
result=refXor(s);
break;
case LONG_ADD_opcode:
result=longAdd(s);
break;
case LONG_AND_opcode:
result=longAnd(s);
break;
case LONG_CMP_opcode:
result=longCmp(s);
break;
case LONG_DIV_opcode:
result=longDiv(s);
break;
case LONG_MUL_opcode:
result=longMul(regpool,s);
break;
case LONG_NEG_opcode:
result=longNeg(s);
break;
case LONG_NOT_opcode:
result=longNot(s);
break;
case LONG_OR_opcode:
result=longOr(s);
break;
case LONG_REM_opcode:
result=longRem(s);
break;
case LONG_SHL_opcode:
result=longShl(s);
break;
case LONG_SHR_opcode:
result=longShr(s);
break;
case LONG_SUB_opcode:
result=longSub(s);
break;
case LONG_USHR_opcode:
result=longUshr(s);
break;
case LONG_XOR_opcode:
result=longXor(s);
break;
case FLOAT_ADD_opcode:
result=floatAdd(s);
break;
case FLOAT_CMPG_opcode:
result=floatCmpg(s);
break;
case FLOAT_CMPL_opcode:
result=floatCmpl(s);
break;
case FLOAT_DIV_opcode:
result=floatDiv(s);
break;
case FLOAT_MUL_opcode:
result=floatMul(s);
break;
case FLOAT_NEG_opcode:
result=floatNeg(s);
break;
case FLOAT_REM_opcode:
result=floatRem(s);
break;
case FLOAT_SUB_opcode:
result=floatSub(s);
break;
case FLOAT_SQRT_opcode:
result=floatSqrt(s);
break;
case DOUBLE_ADD_opcode:
result=doubleAdd(s);
break;
case DOUBLE_CMPG_opcode:
result=doubleCmpg(s);
break;
case DOUBLE_CMPL_opcode:
result=doubleCmpl(s);
break;
case DOUBLE_DIV_opcode:
result=doubleDiv(s);
break;
case DOUBLE_MUL_opcode:
result=doubleMul(s);
break;
case DOUBLE_NEG_opcode:
result=doubleNeg(s);
break;
case DOUBLE_REM_opcode:
result=doubleRem(s);
break;
case DOUBLE_SUB_opcode:
result=doubleSub(s);
break;
case DOUBLE_SQRT_opcode:
result=doubleSqrt(s);
break;
case DOUBLE_2FLOAT_opcode:
result=double2Float(s);
break;
case DOUBLE_2INT_opcode:
result=double2Int(s);
break;
case DOUBLE_2LONG_opcode:
result=double2Long(s);
break;
case DOUBLE_AS_LONG_BITS_opcode:
result=doubleAsLongBits(s);
break;
case INT_2DOUBLE_opcode:
result=int2Double(s);
break;
case INT_2BYTE_opcode:
result=int2Byte(s);
break;
case INT_2USHORT_opcode:
result=int2UShort(s);
break;
case INT_2FLOAT_opcode:
result=int2Float(s);
break;
case INT_2LONG_opcode:
result=int2Long(s);
break;
case INT_2ADDRSigExt_opcode:
result=int2AddrSigExt(s);
break;
case INT_2ADDRZerExt_opcode:
result=int2AddrZerExt(s);
break;
case LONG_2ADDR_opcode:
result=long2Addr(s);
break;
case INT_2SHORT_opcode:
result=int2Short(s);
break;
case INT_BITS_AS_FLOAT_opcode:
result=intBitsAsFloat(s);
break;
case ADDR_2INT_opcode:
result=addr2Int(s);
break;
case ADDR_2LONG_opcode:
result=addr2Long(s);
break;
case FLOAT_2DOUBLE_opcode:
result=float2Double(s);
break;
case FLOAT_2INT_opcode:
result=float2Int(s);
break;
case FLOAT_2LONG_opcode:
result=float2Long(s);
break;
case FLOAT_AS_INT_BITS_opcode:
result=floatAsIntBits(s);
break;
case LONG_2FLOAT_opcode:
result=long2Float(s);
break;
case LONG_2INT_opcode:
result=long2Int(s);
break;
case LONG_2DOUBLE_opcode:
result=long2Double(s);
break;
case LONG_BITS_AS_DOUBLE_opcode:
result=longBitsAsDouble(s);
break;
case ARRAYLENGTH_opcode:
result=arrayLength(s);
break;
case BOUNDS_CHECK_opcode:
result=boundsCheck(s);
break;
case CALL_opcode:
result=call(hir,regpool,s);
break;
case GETFIELD_opcode:
result=getField(s);
break;
case GET_OBJ_TIB_opcode:
result=getObjTib(s);
break;
case GET_CLASS_TIB_opcode:
result=getClassTib(s);
break;
case GET_TYPE_FROM_TIB_opcode:
result=getTypeFromTib(s);
break;
case GET_ARRAY_ELEMENT_TIB_FROM_TIB_opcode:
result=getArrayElementTibFromTib(s);
break;
case GET_SUPERCLASS_IDS_FROM_TIB_opcode:
result=getSuperclassIdsFromTib(s);
break;
case GET_DOES_IMPLEMENT_FROM_TIB_opcode:
result=getDoesImplementFromTib(s);
break;
case REF_LOAD_opcode:
result=refLoad(s);
break;
default :
result=DefUseEffect.UNCHANGED;
}
if (VM.VerifyAssertions) {
switch (result) {
case MOVE_FOLDED:
VM._assert(Move.conforms(s) && (Move.getVal(s) instanceof ConstantOperand),"String_Node_Str" + s + "String_Node_Str"+ OperatorNames.operatorName[opcode]);
break;
case MOVE_REDUCED:
VM._assert(Move.conforms(s) && !(Move.getVal(s) instanceof ConstantOperand),"String_Node_Str" + s + "String_Node_Str"+ OperatorNames.operatorName[opcode]);
break;
default :
}
}
return result;
}