Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/loopUnswitch.cpp @ 3345:bad7ecd0b6ed
5091921: Sign flip issues in loop optimizer
Summary: Fix integer overflow problem in the code generated by loop optimizer.
Reviewed-by: never
author | kvn |
---|---|
date | Wed, 04 May 2011 13:12:42 -0700 |
parents | 6c97c830fb6f |
children | c96c3eb1efae |
comparison
equal
deleted
inserted
replaced
3344:0139aac70fb5 | 3345:bad7ecd0b6ed |
---|---|
128 | 128 |
129 #ifdef ASSERT | 129 #ifdef ASSERT |
130 Node* uniqc = proj_true->unique_ctrl_out(); | 130 Node* uniqc = proj_true->unique_ctrl_out(); |
131 Node* entry = head->in(LoopNode::EntryControl); | 131 Node* entry = head->in(LoopNode::EntryControl); |
132 Node* predicate = find_predicate(entry); | 132 Node* predicate = find_predicate(entry); |
133 if (predicate != NULL && LoopLimitCheck && UseLoopPredicate) { | |
134 // We may have two predicates, find first. | |
135 entry = find_predicate(entry->in(0)->in(0)); | |
136 if (entry != NULL) predicate = entry; | |
137 } | |
133 if (predicate != NULL) predicate = predicate->in(0); | 138 if (predicate != NULL) predicate = predicate->in(0); |
134 assert(proj_true->is_IfTrue() && | 139 assert(proj_true->is_IfTrue() && |
135 (predicate == NULL && uniqc == head || | 140 (predicate == NULL && uniqc == head || |
136 predicate != NULL && uniqc == predicate), "by construction"); | 141 predicate != NULL && uniqc == predicate), "by construction"); |
137 #endif | 142 #endif |
215 // and inserting an if to select fast-slow versions. | 220 // and inserting an if to select fast-slow versions. |
216 // Return control projection of the entry to the fast version. | 221 // Return control projection of the entry to the fast version. |
217 ProjNode* PhaseIdealLoop::create_slow_version_of_loop(IdealLoopTree *loop, | 222 ProjNode* PhaseIdealLoop::create_slow_version_of_loop(IdealLoopTree *loop, |
218 Node_List &old_new) { | 223 Node_List &old_new) { |
219 LoopNode* head = loop->_head->as_Loop(); | 224 LoopNode* head = loop->_head->as_Loop(); |
225 bool counted_loop = head->is_CountedLoop(); | |
220 Node* entry = head->in(LoopNode::EntryControl); | 226 Node* entry = head->in(LoopNode::EntryControl); |
221 _igvn.hash_delete(entry); | 227 _igvn.hash_delete(entry); |
222 _igvn._worklist.push(entry); | 228 _igvn._worklist.push(entry); |
223 IdealLoopTree* outer_loop = loop->_parent; | 229 IdealLoopTree* outer_loop = loop->_parent; |
224 | 230 |
240 // (old & new loops & new if). | 246 // (old & new loops & new if). |
241 clone_loop(loop, old_new, dom_depth(head), iff); | 247 clone_loop(loop, old_new, dom_depth(head), iff); |
242 assert(old_new[head->_idx]->is_Loop(), "" ); | 248 assert(old_new[head->_idx]->is_Loop(), "" ); |
243 | 249 |
244 // Fast (true) control | 250 // Fast (true) control |
245 Node* iffast_pred = clone_loop_predicates(entry, iffast); | 251 Node* iffast_pred = clone_loop_predicates(entry, iffast, !counted_loop); |
246 _igvn.hash_delete(head); | 252 _igvn.hash_delete(head); |
247 head->set_req(LoopNode::EntryControl, iffast_pred); | 253 head->set_req(LoopNode::EntryControl, iffast_pred); |
248 set_idom(head, iffast_pred, dom_depth(head)); | 254 set_idom(head, iffast_pred, dom_depth(head)); |
249 _igvn._worklist.push(head); | 255 _igvn._worklist.push(head); |
250 | 256 |
251 // Slow (false) control | 257 // Slow (false) control |
252 Node* ifslow_pred = move_loop_predicates(entry, ifslow); | 258 Node* ifslow_pred = move_loop_predicates(entry, ifslow, !counted_loop); |
253 LoopNode* slow_head = old_new[head->_idx]->as_Loop(); | 259 LoopNode* slow_head = old_new[head->_idx]->as_Loop(); |
254 _igvn.hash_delete(slow_head); | 260 _igvn.hash_delete(slow_head); |
255 slow_head->set_req(LoopNode::EntryControl, ifslow_pred); | 261 slow_head->set_req(LoopNode::EntryControl, ifslow_pred); |
256 set_idom(slow_head, ifslow_pred, dom_depth(slow_head)); | 262 set_idom(slow_head, ifslow_pred, dom_depth(slow_head)); |
257 _igvn._worklist.push(slow_head); | 263 _igvn._worklist.push(slow_head); |