Skip to content

Commit bca1970

Browse files
committed
8223143: Restructure/clean-up for 'loopexit_or_null()'.
Minor restructure and clean-up for 'loopexit_or_null()' and its use. Backport-of: 8088ed8
1 parent 571d323 commit bca1970

File tree

1 file changed

+41
-19
lines changed

1 file changed

+41
-19
lines changed

src/hotspot/share/opto/loopnode.hpp

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -370,26 +370,49 @@ class CountedLoopEndNode : public IfNode {
370370
};
371371

372372

373-
inline CountedLoopEndNode *CountedLoopNode::loopexit_or_null() const {
374-
Node *bc = back_control();
375-
if( bc == NULL ) return NULL;
376-
Node *le = bc->in(0);
377-
if( le->Opcode() != Op_CountedLoopEnd )
378-
return NULL;
379-
return (CountedLoopEndNode*)le;
373+
inline CountedLoopEndNode* CountedLoopNode::loopexit_or_null() const {
374+
Node* bctrl = back_control();
375+
if (bctrl == NULL) return NULL;
376+
377+
Node* lexit = bctrl->in(0);
378+
return (CountedLoopEndNode*)
379+
(lexit->Opcode() == Op_CountedLoopEnd ? lexit : NULL);
380380
}
381-
inline CountedLoopEndNode *CountedLoopNode::loopexit() const {
381+
382+
inline CountedLoopEndNode* CountedLoopNode::loopexit() const {
382383
CountedLoopEndNode* cle = loopexit_or_null();
383384
assert(cle != NULL, "loopexit is NULL");
384385
return cle;
385386
}
386-
inline Node *CountedLoopNode::init_trip() const { return loopexit_or_null() ? loopexit()->init_trip() : NULL; }
387-
inline Node *CountedLoopNode::stride() const { return loopexit_or_null() ? loopexit()->stride() : NULL; }
388-
inline int CountedLoopNode::stride_con() const { return loopexit_or_null() ? loopexit()->stride_con() : 0; }
389-
inline bool CountedLoopNode::stride_is_con() const { return loopexit_or_null() && loopexit()->stride_is_con(); }
390-
inline Node *CountedLoopNode::limit() const { return loopexit_or_null() ? loopexit()->limit() : NULL; }
391-
inline Node *CountedLoopNode::incr() const { return loopexit_or_null() ? loopexit()->incr() : NULL; }
392-
inline Node *CountedLoopNode::phi() const { return loopexit_or_null() ? loopexit()->phi() : NULL; }
387+
388+
inline Node* CountedLoopNode::init_trip() const {
389+
CountedLoopEndNode* cle = loopexit_or_null();
390+
return cle != NULL ? cle->init_trip() : NULL;
391+
}
392+
inline Node* CountedLoopNode::stride() const {
393+
CountedLoopEndNode* cle = loopexit_or_null();
394+
return cle != NULL ? cle->stride() : NULL;
395+
}
396+
inline int CountedLoopNode::stride_con() const {
397+
CountedLoopEndNode* cle = loopexit_or_null();
398+
return cle != NULL ? cle->stride_con() : 0;
399+
}
400+
inline bool CountedLoopNode::stride_is_con() const {
401+
CountedLoopEndNode* cle = loopexit_or_null();
402+
return cle != NULL && cle->stride_is_con();
403+
}
404+
inline Node* CountedLoopNode::limit() const {
405+
CountedLoopEndNode* cle = loopexit_or_null();
406+
return cle != NULL ? cle->limit() : NULL;
407+
}
408+
inline Node* CountedLoopNode::incr() const {
409+
CountedLoopEndNode* cle = loopexit_or_null();
410+
return cle != NULL ? cle->incr() : NULL;
411+
}
412+
inline Node* CountedLoopNode::phi() const {
413+
CountedLoopEndNode* cle = loopexit_or_null();
414+
return cle != NULL ? cle->phi() : NULL;
415+
}
393416

394417
//------------------------------LoopLimitNode-----------------------------
395418
// Counted Loop limit node which represents exact final iterator value:
@@ -635,8 +658,8 @@ class IdealLoopTree : public ResourceObj {
635658
};
636659

637660
// -----------------------------PhaseIdealLoop---------------------------------
638-
// Computes the mapping from Nodes to IdealLoopTrees. Organizes IdealLoopTrees into a
639-
// loop tree. Drives the loop-based transformations on the ideal graph.
661+
// Computes the mapping from Nodes to IdealLoopTrees. Organizes IdealLoopTrees
662+
// into a loop tree. Drives the loop-based transformations on the ideal graph.
640663
class PhaseIdealLoop : public PhaseTransform {
641664
friend class IdealLoopTree;
642665
friend class SuperWord;
@@ -735,8 +758,7 @@ class PhaseIdealLoop : public PhaseTransform {
735758
}
736759
Node *dom_lca_for_get_late_ctrl_internal( Node *lca, Node *n, Node *tag );
737760

738-
// Helper function for directing control inputs away from CFG split
739-
// points.
761+
// Helper function for directing control inputs away from CFG split points.
740762
Node *find_non_split_ctrl( Node *ctrl ) const {
741763
if (ctrl != NULL) {
742764
if (ctrl->is_MultiBranch()) {

0 commit comments

Comments
 (0)