8159715: Fix for 8072422 is incorrect

Fixed several issues introduced by 8072422.

Reviewed-by: zmajo, kvn
This commit is contained in:
Tobias Hartmann 2016-06-20 09:32:44 +02:00
parent 063397934d
commit 6294f0770b
4 changed files with 9 additions and 26 deletions

View File

@ -868,7 +868,7 @@ bool IdealLoopTree::policy_range_check( PhaseIdealLoop *phase ) const {
Node *bol = iff->in(1);
if (bol->req() != 2) continue; // dead constant test
if (!bol->is_Bool()) {
assert(UseLoopPredicate && bol->Opcode() == Op_Conv2B, "predicate check only");
assert(bol->Opcode() == Op_Conv2B, "predicate check only");
continue;
}
if (bol->as_Bool()->_test._test == BoolTest::ne)
@ -1760,14 +1760,6 @@ void PhaseIdealLoop::mark_reductions(IdealLoopTree *loop) {
}
}
//------------------------------dominates_backedge---------------------------------
// Returns true if ctrl is executed on every complete iteration
bool IdealLoopTree::dominates_backedge(Node* ctrl) {
assert(ctrl->is_CFG(), "must be control");
Node* backedge = _head->as_Loop()->in(LoopNode::LoopBackControl);
return _phase->dom_lca_internal(ctrl, backedge) == ctrl;
}
//------------------------------adjust_limit-----------------------------------
// Helper function for add_constraint().
Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl) {
@ -2187,10 +2179,8 @@ int PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) {
if( b_test._test == BoolTest::lt ) { // Range checks always use lt
// The underflow and overflow limits: 0 <= scale*I+offset < limit
add_constraint( stride_con, scale_con, offset, zero, limit, pre_ctrl, &pre_limit, &main_limit );
if (!conditional_rc) {
// (0-offset)/scale could be outside of loop iterations range.
conditional_rc = !loop->dominates_backedge(iff);
}
// (0-offset)/scale could be outside of loop iterations range.
conditional_rc = true;
} else {
if (PrintOpto) {
tty->print_cr("missed RCE opportunity");
@ -2221,12 +2211,10 @@ int PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) {
// Note: (MIN_INT+1 == -MAX_INT) is used instead of MIN_INT here
// to avoid problem with scale == -1: MIN_INT/(-1) == MIN_INT.
add_constraint( stride_con, scale_con, offset, mini, limit, pre_ctrl, &pre_limit, &main_limit );
if (!conditional_rc) {
// ((MIN_INT+1)-offset)/scale could be outside of loop iterations range.
// Note: negative offset is replaced with 0 but (MIN_INT+1)/scale could
// still be outside of loop range.
conditional_rc = !loop->dominates_backedge(iff);
}
// ((MIN_INT+1)-offset)/scale could be outside of loop iterations range.
// Note: negative offset is replaced with 0 but (MIN_INT+1)/scale could
// still be outside of loop range.
conditional_rc = true;
break;
default:
if (PrintOpto) {

View File

@ -2225,9 +2225,7 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts)
// Some parser-inserted loop predicates could never be used by loop
// predication or they were moved away from loop during some optimizations.
// For example, peeling. Eliminate them before next loop optimizations.
if (UseLoopPredicate) {
eliminate_useless_predicates();
}
eliminate_useless_predicates();
#ifndef PRODUCT
C->verify_graph_edges();

View File

@ -468,9 +468,6 @@ public:
// Check for Node being a loop-breaking test
Node *is_loop_exit(Node *iff) const;
// Returns true if ctrl is executed on every complete iteration
bool dominates_backedge(Node* ctrl);
// Remove simplistic dead code from loop body
void DCE_loop_body();

View File

@ -662,7 +662,7 @@ void Parse::do_all_blocks() {
// (Note that dead locals do not get phis built, ever.)
ensure_phis_everywhere();
if (block->is_SEL_head() && UseLoopPredicate) {
if (block->is_SEL_head()) {
// Add predicate to single entry (not irreducible) loop head.
assert(!block->has_merged_backedge(), "only entry paths should be merged for now");
// Need correct bci for predicate.