src/share/vm/c1/c1_LinearScan.cpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:

*** 6229,6243 **** LIR_Op* prev_op = instructions->at(instructions->length() - 2); if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) { assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch"); LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op; LIR_Op2* prev_cmp = NULL; for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { prev_op = instructions->at(j); ! if(prev_op->code() == lir_cmp) { assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); prev_cmp = (LIR_Op2*)prev_op; assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); } } --- 6229,6245 ---- LIR_Op* prev_op = instructions->at(instructions->length() - 2); if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) { assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch"); LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op; + if (prev_branch->stub() == NULL) { + LIR_Op2* prev_cmp = NULL; for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { prev_op = instructions->at(j); ! if (prev_op->code() == lir_cmp) { assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); prev_cmp = (LIR_Op2*)prev_op; assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); } }
*** 6254,6263 **** --- 6256,6266 ---- } } } } } + } } DEBUG_ONLY(verify(code)); }