src/share/vm/c1/c1_LinearScan.cpp

changeset 4860
46f6f063b272
parent 4153
b9a9ed0f8eeb
child 5994
9acbfe04b5c3
equal deleted inserted replaced
4780:98f3af397705 4860:46f6f063b272
6229 LIR_Op* prev_op = instructions->at(instructions->length() - 2); 6229 LIR_Op* prev_op = instructions->at(instructions->length() - 2);
6230 if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) { 6230 if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) {
6231 assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch"); 6231 assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch");
6232 LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op; 6232 LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op;
6233 6233
6234 LIR_Op2* prev_cmp = NULL; 6234 if (prev_branch->stub() == NULL) {
6235 6235
6236 for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { 6236 LIR_Op2* prev_cmp = NULL;
6237 prev_op = instructions->at(j); 6237
6238 if(prev_op->code() == lir_cmp) { 6238 for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) {
6239 assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); 6239 prev_op = instructions->at(j);
6240 prev_cmp = (LIR_Op2*)prev_op; 6240 if (prev_op->code() == lir_cmp) {
6241 assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); 6241 assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2");
6242 prev_cmp = (LIR_Op2*)prev_op;
6243 assert(prev_branch->cond() == prev_cmp->condition(), "should be the same");
6244 }
6242 } 6245 }
6243 } 6246 assert(prev_cmp != NULL, "should have found comp instruction for branch");
6244 assert(prev_cmp != NULL, "should have found comp instruction for branch"); 6247 if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) {
6245 if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) { 6248
6246 6249 TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id()));
6247 TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id())); 6250
6248 6251 // eliminate a conditional branch to the immediate successor
6249 // eliminate a conditional branch to the immediate successor 6252 prev_branch->change_block(last_branch->block());
6250 prev_branch->change_block(last_branch->block()); 6253 prev_branch->negate_cond();
6251 prev_branch->negate_cond(); 6254 prev_cmp->set_condition(prev_branch->cond());
6252 prev_cmp->set_condition(prev_branch->cond()); 6255 instructions->truncate(instructions->length() - 1);
6253 instructions->truncate(instructions->length() - 1); 6256 }
6254 } 6257 }
6255 } 6258 }
6256 } 6259 }
6257 } 6260 }
6258 } 6261 }

mercurial