277
278 CountedLoopEndNode( Node *control, Node *test, float prob, float cnt )
279 : IfNode( control, test, prob, cnt) {
280 init_class_id(Class_CountedLoopEnd);
281 }
282 virtual int Opcode() const;
283
284 Node *cmp_node() const { return (in(TestValue)->req() >=2) ? in(TestValue)->in(1) : NULL; }
285 Node *incr() const { Node *tmp = cmp_node(); return (tmp && tmp->req()==3) ? tmp->in(1) : NULL; }
286 Node *limit() const { Node *tmp = cmp_node(); return (tmp && tmp->req()==3) ? tmp->in(2) : NULL; }
287 Node *stride() const { Node *tmp = incr (); return (tmp && tmp->req()==3) ? tmp->in(2) : NULL; }
288 Node *phi() const { Node *tmp = incr (); return (tmp && tmp->req()==3) ? tmp->in(1) : NULL; }
289 Node *init_trip() const { Node *tmp = phi (); return (tmp && tmp->req()==3) ? tmp->in(1) : NULL; }
290 int stride_con() const;
291 bool stride_is_con() const { Node *tmp = stride (); return (tmp != NULL && tmp->is_Con()); }
292 BoolTest::mask test_trip() const { return in(TestValue)->as_Bool()->_test._test; }
293 CountedLoopNode *loopnode() const {
294 // The CountedLoopNode that goes with this CountedLoopEndNode may
295 // have been optimized out by the IGVN so be cautious with the
296 // pattern matching on the graph
297 if (phi() == NULL) {
298 return NULL;
299 }
300 assert(phi()->is_Phi(), "should be PhiNode");
301 Node *ln = phi()->in(0);
302 if (ln->is_CountedLoop() && ln->as_CountedLoop()->loopexit() == this) {
303 return (CountedLoopNode*)ln;
304 }
305 return NULL;
306 }
307
308 #ifndef PRODUCT
309 virtual void dump_spec(outputStream *st) const;
310 #endif
311 };
312
313
314 inline CountedLoopEndNode *CountedLoopNode::loopexit() const {
315 Node *bc = back_control();
316 if( bc == NULL ) return NULL;
317 Node *le = bc->in(0);
318 if( le->Opcode() != Op_CountedLoopEnd )
319 return NULL;
320 return (CountedLoopEndNode*)le;
|
277
278 CountedLoopEndNode( Node *control, Node *test, float prob, float cnt )
279 : IfNode( control, test, prob, cnt) {
280 init_class_id(Class_CountedLoopEnd);
281 }
282 virtual int Opcode() const;
283
284 Node *cmp_node() const { return (in(TestValue)->req() >=2) ? in(TestValue)->in(1) : NULL; }
285 Node *incr() const { Node *tmp = cmp_node(); return (tmp && tmp->req()==3) ? tmp->in(1) : NULL; }
286 Node *limit() const { Node *tmp = cmp_node(); return (tmp && tmp->req()==3) ? tmp->in(2) : NULL; }
287 Node *stride() const { Node *tmp = incr (); return (tmp && tmp->req()==3) ? tmp->in(2) : NULL; }
288 Node *phi() const { Node *tmp = incr (); return (tmp && tmp->req()==3) ? tmp->in(1) : NULL; }
289 Node *init_trip() const { Node *tmp = phi (); return (tmp && tmp->req()==3) ? tmp->in(1) : NULL; }
290 int stride_con() const;
291 bool stride_is_con() const { Node *tmp = stride (); return (tmp != NULL && tmp->is_Con()); }
292 BoolTest::mask test_trip() const { return in(TestValue)->as_Bool()->_test._test; }
293 CountedLoopNode *loopnode() const {
294 // The CountedLoopNode that goes with this CountedLoopEndNode may
295 // have been optimized out by the IGVN so be cautious with the
296 // pattern matching on the graph
297 Node* iv_phi = phi();
298 if (iv_phi == NULL || !iv_phi->is_Phi()) {
299 return NULL;
300 }
301 Node *ln = phi()->in(0);
302 if (ln->is_CountedLoop() && ln->as_CountedLoop()->loopexit() == this) {
303 return (CountedLoopNode*)ln;
304 }
305 return NULL;
306 }
307
308 #ifndef PRODUCT
309 virtual void dump_spec(outputStream *st) const;
310 #endif
311 };
312
313
314 inline CountedLoopEndNode *CountedLoopNode::loopexit() const {
315 Node *bc = back_control();
316 if( bc == NULL ) return NULL;
317 Node *le = bc->in(0);
318 if( le->Opcode() != Op_CountedLoopEnd )
319 return NULL;
320 return (CountedLoopEndNode*)le;
|