Skip to content

Commit

Permalink
remove not dead
Browse files Browse the repository at this point in the history
  • Loading branch information
chhagedorn committed Nov 24, 2023
1 parent 4adafbd commit 4bfd23d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/loopPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ IfProjNode* PhaseIdealLoop::clone_assertion_predicate_for_unswitched_loops(Node*
opaque_node = clone_and_register(opaque_node, parse_predicate_proj);
_igvn.replace_input_of(opaque_node, 1, bol);
IfProjNode* if_proj = create_new_if_for_predicate(parse_predicate_proj, nullptr, reason, iff->Opcode(), false);
_igvn.replace_input_of(if_proj->in(0), 1, bol);
_igvn.replace_input_of(if_proj->in(0), 1, opaque_node);
_igvn.replace_input_of(parse_predicate_proj->in(0), 0, if_proj);
set_idom(parse_predicate_proj->in(0), if_proj, dom_depth(if_proj));
return if_proj;
Expand Down
30 changes: 12 additions & 18 deletions src/hotspot/share/opto/predicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,21 @@ Node* PredicateBlock::skip_regular_predicates(Node* regular_predicate_proj, Deop
return entry;
}

TemplateAssertionPredicateBool::TemplateAssertionPredicateBool(Node* source_bool) : _source_bool(source_bool->isa_Bool()) {
TemplateAssertionPredicateBool::TemplateAssertionPredicateBool(Node* source_bool) : _source_bool(source_bool->as_Bool()) {
#ifdef ASSERT
// We could have already folded the BoolNode to a constant.
if (is_not_dead()) {
// During IGVN, we could have multiple outputs of the _source_bool, for example, when the backedge of the loop of
// this Template Assertion Predicate is about to die and the CastII on the last value bool already folded to a
// constant (i.e. no OpaqueLoop* nodes anymore). Then IGVN could already have commoned up the bool with the bool of
// one of the Hoisted Check Predicates. Just check that the Template Assertion Predicate is one of the outputs.
bool has_template_output = false;
for (DUIterator_Fast imax, i = source_bool->fast_outs(imax); i < imax; i++) {
Node* out = source_bool->fast_out(i);
if (out->Opcode() == Op_Opaque4) {
has_template_output = true;
break;
}
// During IGVN, we could have multiple outputs of the _source_bool, for example, when the backedge of the loop of
// this Template Assertion Predicate is about to die and the CastII on the last value bool already folded to a
// constant (i.e. no OpaqueLoop* nodes anymore). Then IGVN could already have commoned up the bool with the bool of
// one of the Hoisted Check Predicates. Just check that the Template Assertion Predicate is one of the outputs.
bool has_template_output = false;
for (DUIterator_Fast imax, i = source_bool->fast_outs(imax); i < imax; i++) {
Node* out = source_bool->fast_out(i);
if (out->Opcode() == Op_Opaque4) {
has_template_output = true;
break;
}
assert(has_template_output, "must find Template Assertion Predicate as output");
}
assert(has_template_output, "must find Template Assertion Predicate as output");
#endif // ASSERT
}

Expand Down Expand Up @@ -405,7 +402,6 @@ class CloneOpaqueLoopNodes : public TransformOpaqueLoopNodes {
// Clones this Template Assertion Predicate bool. This includes all nodes from the BoolNode to the OpaqueLoop* nodes.
// The cloned nodes are not updated.
BoolNode* TemplateAssertionPredicateBool::clone(Node* new_ctrl, PhaseIdealLoop* phase) {
assert(is_not_dead(), "must not be dead");
CloneOpaqueLoopNodes clone_opaque_loop_nodes(phase, new_ctrl);
CloneAssertionPredicateBool clone_assertion_predicate_bool(_source_bool, new_ctrl, phase);
return clone_assertion_predicate_bool.clone(&clone_opaque_loop_nodes);
Expand Down Expand Up @@ -436,7 +432,6 @@ class CloneWithNewInit : public TransformOpaqueLoopNodes {
// not updated.
BoolNode* TemplateAssertionPredicateBool::clone_and_replace_init(Node* new_ctrl, Node* new_init,
PhaseIdealLoop* phase) {
assert(is_not_dead(), "must not be dead");
CloneWithNewInit clone_with_new_init(phase, new_ctrl, new_init);
CloneAssertionPredicateBool clone_assertion_predicate_bool(_source_bool, new_ctrl, phase);
return clone_assertion_predicate_bool.clone(&clone_with_new_init);
Expand Down Expand Up @@ -464,7 +459,6 @@ class ReplaceOpaqueLoopNodes : public TransformOpaqueLoopNodes {
// The cloned nodes are not updated.
BoolNode* TemplateAssertionPredicateBool::clone_and_replace_opaque_loop_nodes(Node* new_ctrl, Node* new_init,
Node* new_stride, PhaseIdealLoop* phase) {
assert(is_not_dead(), "must not be dead");
ReplaceOpaqueLoopNodes replaceOpaqueLoopNodes(new_init, new_stride);
CloneAssertionPredicateBool clone_assertion_predicate_bool(_source_bool, new_ctrl, phase);
return clone_assertion_predicate_bool.clone(&replaceOpaqueLoopNodes);
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/share/opto/predicates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ class TemplateAssertionPredicateBool : public StackObj {
public:
explicit TemplateAssertionPredicateBool(Node* source_bool);

// The last value bool could already be a constant (i.e. dead) when the CastII node between the Template Assertion
// Predicate and the OpaqueLoop* nodes was replaced by a constant. In this case, _source_bool is null.
bool is_not_dead() const {
return _source_bool != nullptr;
}

BoolNode* clone(Node* new_ctrl, PhaseIdealLoop* phase);
BoolNode* clone_and_replace_init(Node* new_ctrl, Node* new_init, PhaseIdealLoop* phase);
BoolNode* clone_and_replace_opaque_loop_nodes(Node* new_ctrl, Node* new_init, Node* new_stride, PhaseIdealLoop* phase);
Expand Down

0 comments on commit 4bfd23d

Please sign in to comment.