Skip to content

Commit

Permalink
Make OpaqueInitializedAssertionPredicateNode a macro node again
Browse files Browse the repository at this point in the history
  • Loading branch information
chhagedorn committed May 15, 2024
1 parent b2dfffe commit 5b9ec6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/hotspot/share/opto/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,7 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
assert(n->Opcode() == Op_LoopLimit ||
n->Opcode() == Op_Opaque3 ||
n->is_Opaque4() ||
n->is_OpaqueInitializedAssertionPredicate() ||
n->Opcode() == Op_MaxL ||
n->Opcode() == Op_MinL ||
BarrierSet::barrier_set()->barrier_set_c2()->is_gc_barrier_node(n),
Expand Down Expand Up @@ -2518,6 +2519,17 @@ bool PhaseMacroExpand::expand_macro_nodes() {
_igvn.replace_node(n, n->in(2));
#endif
success = true;
} else if (n->is_OpaqueInitializedAssertionPredicate()) {
// Initialized Assertion Predicates must always evaluate to true. Therefore, we get rid of them in product
// builds as they are useless. In debug builds we keep them as additional verification code. Even though
// loop opts are already over, we want to keep Initialized Assertion Predicates alive as long as possible to
// enable folding of dead control paths within which cast nodes become top after due to impossible types -
// even after loop opts are over. Therefore, we delay the removal of these opaque nodes until now.
#ifdef ASSERT
_igvn.replace_node(n, n->in(1));
#else
_igvn.replace_node(n, _igvn.intcon(1));
#endif // ASSERT
} else if (n->Opcode() == Op_OuterStripMinedLoop) {
n->as_OuterStripMinedLoop()->adjust_strip_mined_loop(&_igvn);
C->remove_macro_node(n);
Expand Down
9 changes: 4 additions & 5 deletions src/hotspot/share/opto/opaquenode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ class Opaque3Node : public Node {
// GraphKit::must_be_not_null().
class Opaque4Node : public Node {
public:
Opaque4Node(Compile* C, Node *tst, Node* final_tst) : Node(nullptr, tst, final_tst) {
Opaque4Node(Compile* C, Node* tst, Node* final_tst) : Node(nullptr, tst, final_tst) {
init_class_id(Class_Opaque4);
init_flags(Flag_is_macro);
C->add_macro_node(this);
}

virtual int Opcode() const;
virtual const Type *bottom_type() const { return TypeInt::BOOL; }
virtual const Type* Value(PhaseGVN* phase) const;
virtual const Type* bottom_type() const { return TypeInt::BOOL; }
};

// This node is used for Initialized Assertion Predicate BoolNodes. Initialized Assertion Predicates must always evaluate
// to true. Therefore, we get rid of them in product builds as they are useless. In debug builds we keep them as
// additional verification code (i.e. removing this node and use the BoolNode input instead).
// to true. Therefore, we get rid of them in product builds during macro expansion as they are useless. In debug builds
// we keep them as additional verification code (i.e. removing this node and use the BoolNode input instead).
class OpaqueInitializedAssertionPredicateNode : public Node {
public:
OpaqueInitializedAssertionPredicateNode(BoolNode* bol, Compile* C) : Node(nullptr, bol) {
Expand All @@ -144,7 +144,6 @@ class OpaqueInitializedAssertionPredicateNode : public Node {
}

virtual int Opcode() const;
virtual Node* Identity(PhaseGVN* phase);
virtual const Type* Value(PhaseGVN* phase) const;
virtual const Type* bottom_type() const { return TypeInt::BOOL; }
};
Expand Down

0 comments on commit 5b9ec6e

Please sign in to comment.