Skip to content

Commit

Permalink
8330165: C2: make superword consistently use PhaseIdealLoop::register…
Browse files Browse the repository at this point in the history
…_new_node()

Reviewed-by: chagedorn, kvn
  • Loading branch information
rwestrel committed Apr 16, 2024
1 parent e073d5b commit bfff02e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/loopTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Node* IdealLoopTree::reassociate(Node* n1, PhaseIdealLoop *phase) {
}

assert(result != nullptr, "");
phase->register_new_node(result, phase->get_ctrl(n1));
phase->register_new_node_with_ctrl_of(result, n1);
phase->_igvn.replace_node(n1, result);
assert(phase->get_loop(phase->get_ctrl(n1)) == this, "");
_body.yank(n1);
Expand Down Expand Up @@ -2215,7 +2215,7 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
// Limit is not constant. Int subtraction could lead to underflow.
// (1) Convert to long.
Node* limit_l = new ConvI2LNode(limit);
register_new_node(limit_l, get_ctrl(limit));
register_new_node_with_ctrl_of(limit_l, limit);
Node* stride_l = _igvn.longcon(stride_con);
set_ctrl(stride_l, C->root());

Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/opto/loopnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,9 @@ class PhaseIdealLoop : public PhaseTransform {
void set_created_loop_node() { _created_loop_node = true; }
bool created_loop_node() { return _created_loop_node; }
void register_new_node(Node* n, Node* blk);
void register_new_node_with_ctrl_of(Node* new_node, Node* ctrl_of) {
register_new_node(new_node, get_ctrl(ctrl_of));
}

Node* clone_and_register(Node* n, Node* ctrl) {
n = n->clone();
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/opto/loopopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ Node* PhaseIdealLoop::remix_address_expressions_add_left_shift(Node* n, IdealLoo
Node* zero = _igvn.integercon(0, bt);
set_ctrl(zero, C->root());
Node* neg = SubNode::make(zero, add->in(2), bt);
register_new_node(neg, get_ctrl(add->in(2)));
register_new_node_with_ctrl_of(neg, add->in(2));
add = AddNode::make(add->in(1), neg, bt);
register_new_node(add, add_ctrl);
}
Expand Down Expand Up @@ -654,13 +654,13 @@ Node *PhaseIdealLoop::convert_add_to_muladd(Node* n) {
if ((adr1->in(AddPNode::Base) == adr3->in(AddPNode::Base)) &&
(adr2->in(AddPNode::Base) == adr4->in(AddPNode::Base))) {
nn = new MulAddS2INode(mul_in1, mul_in2, mul_in3, mul_in4);
register_new_node(nn, get_ctrl(n));
register_new_node_with_ctrl_of(nn, n);
_igvn.replace_node(n, nn);
return nn;
} else if ((adr1->in(AddPNode::Base) == adr4->in(AddPNode::Base)) &&
(adr2->in(AddPNode::Base) == adr3->in(AddPNode::Base))) {
nn = new MulAddS2INode(mul_in1, mul_in2, mul_in4, mul_in3);
register_new_node(nn, get_ctrl(n));
register_new_node_with_ctrl_of(nn, n);
_igvn.replace_node(n, nn);
return nn;
}
Expand Down Expand Up @@ -2268,7 +2268,7 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new,
// that access. If that condition is replaced by an identical dominating one, then an unpinned load would risk
// floating above its range check.
pinned_clone->set_req(0, phi);
register_new_node(pinned_clone, get_ctrl(use));
register_new_node_with_ctrl_of(pinned_clone, use);
_igvn.replace_node(use, pinned_clone);
continue;
}
Expand Down Expand Up @@ -3914,7 +3914,7 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) {
// floating above its range check.
Node* pinned_clone = n_clone->pin_array_access_node();
if (pinned_clone != nullptr) {
register_new_node(pinned_clone, get_ctrl(n_clone));
register_new_node_with_ctrl_of(pinned_clone, n_clone);
old_new.map(n->_idx, pinned_clone);
_igvn.replace_node(n_clone, pinned_clone);
n_clone = pinned_clone;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/split_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ void PhaseIdealLoop::pin_array_access_nodes_dependent_on(Node* ctrl) {
}
Node* pinned_clone = use->pin_array_access_node();
if (pinned_clone != nullptr) {
register_new_node(pinned_clone, get_ctrl(use));
register_new_node_with_ctrl_of(pinned_clone, use);
_igvn.replace_node(use, pinned_clone);
--i;
}
Expand Down
62 changes: 23 additions & 39 deletions src/hotspot/share/opto/superword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "opto/memnode.hpp"
#include "opto/opcodes.hpp"
#include "opto/opaquenode.hpp"
#include "opto/rootnode.hpp"
#include "opto/superword.hpp"
#include "opto/vectornode.hpp"
#include "opto/movenode.hpp"
Expand Down Expand Up @@ -2553,8 +2554,7 @@ bool SuperWord::output() {
BasicType bt = velt_basic_type(cmp);
const TypeVect* vt = TypeVect::make(bt, vlen);
VectorNode* mask = new VectorMaskCmpNode(bol_test, cmp_in1, cmp_in2, bol_test_node, vt);
igvn().register_new_node_with_optimizer(mask);
phase()->set_ctrl(mask, phase()->get_ctrl(p->at(0)));
phase()->register_new_node_with_ctrl_of(mask, p->at(0));
igvn()._worklist.push(mask);

// VectorBlend
Expand Down Expand Up @@ -2628,8 +2628,7 @@ bool SuperWord::output() {
assert(n->req() == 2, "only one input expected");
Node* in = vector_opd(p, 1);
Node* longval = VectorNode::make(opc, in, nullptr, vlen, T_LONG);
igvn().register_new_node_with_optimizer(longval);
phase()->set_ctrl(longval, phase()->get_ctrl(first));
phase()->register_new_node_with_ctrl_of(longval, first);
vn = VectorCastNode::make(Op_VectorCastL2X, longval, T_INT, vlen);
vlen_in_bytes = vn->as_Vector()->length_in_bytes();
} else if (VectorNode::is_convert_opcode(opc)) {
Expand Down Expand Up @@ -2669,8 +2668,7 @@ bool SuperWord::output() {
}
#endif

igvn().register_new_node_with_optimizer(vn);
phase()->set_ctrl(vn, phase()->get_ctrl(first));
phase()->register_new_node_with_ctrl_of(vn, first);
for (uint j = 0; j < p->size(); j++) {
Node* pm = p->at(j);
igvn().replace_node(pm, vn);
Expand Down Expand Up @@ -2739,8 +2737,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
const TypeVect* vt = TypeVect::make(iv_bt, vlen);
Node* vn = new PopulateIndexNode(iv(), igvn().intcon(1), vt);
VectorNode::trace_new_vector(vn, "SuperWord");
igvn().register_new_node_with_optimizer(vn);
phase()->set_ctrl(vn, phase()->get_ctrl(opd));
phase()->register_new_node_with_ctrl_of(vn, opd);
return vn;
}

Expand All @@ -2760,16 +2757,14 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
if (t != nullptr && t->is_con()) {
juint shift = t->get_con();
if (shift > mask) { // Unsigned cmp
cnt = ConNode::make(TypeInt::make(shift & mask));
igvn().register_new_node_with_optimizer(cnt);
cnt = igvn().intcon(shift & mask);
phase()->set_ctrl(cnt, phase()->C->root());
}
} else {
if (t == nullptr || t->_lo < 0 || t->_hi > (int)mask) {
cnt = ConNode::make(TypeInt::make(mask));
igvn().register_new_node_with_optimizer(cnt);
cnt = igvn().intcon(mask);
cnt = new AndINode(opd, cnt);
igvn().register_new_node_with_optimizer(cnt);
phase()->set_ctrl(cnt, phase()->get_ctrl(opd));
phase()->register_new_node_with_ctrl_of(cnt, opd);
}
if (!opd->bottom_type()->isa_int()) {
assert(false, "int type only");
Expand All @@ -2778,8 +2773,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
}
// Move shift count into vector register.
cnt = VectorNode::shift_count(p0->Opcode(), cnt, vlen, velt_basic_type(p0));
igvn().register_new_node_with_optimizer(cnt);
phase()->set_ctrl(cnt, phase()->get_ctrl(opd));
phase()->register_new_node_with_ctrl_of(cnt, opd);
return cnt;
}
if (opd->is_StoreVector()) {
Expand All @@ -2797,17 +2791,15 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
if (p0->bottom_type()->isa_long()) {
p0_t = TypeLong::LONG;
conv = new ConvI2LNode(opd);
igvn().register_new_node_with_optimizer(conv);
phase()->set_ctrl(conv, phase()->get_ctrl(opd));
phase()->register_new_node_with_ctrl_of(conv, opd);
}
vn = VectorNode::scalar2vector(conv, vlen, p0_t);
} else {
p0_t = velt_type(p0);
vn = VectorNode::scalar2vector(opd, vlen, p0_t);
}

igvn().register_new_node_with_optimizer(vn);
phase()->set_ctrl(vn, phase()->get_ctrl(opd));
phase()->register_new_node_with_ctrl_of(vn, opd);
VectorNode::trace_new_vector(vn, "SuperWord");
return vn;
}
Expand Down Expand Up @@ -2836,8 +2828,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) {
pk->add_opd(in2);
}
}
igvn().register_new_node_with_optimizer(pk);
phase()->set_ctrl(pk, phase()->get_ctrl(opd));
phase()->register_new_node_with_ctrl_of(pk, opd);
VectorNode::trace_new_vector(pk, "SuperWord");
return pk;
}
Expand Down Expand Up @@ -3640,16 +3631,15 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() {
// safe to simply convert invar to an int and loose the upper 32
// bit half.
invar = new ConvL2INode(invar);
igvn().register_new_node_with_optimizer(invar);
phase()->register_new_node(invar, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(invar);
}
if (is_sub) {
xboi = new SubINode(xboi, invar);
} else {
xboi = new AddINode(xboi, invar);
}
igvn().register_new_node_with_optimizer(xboi);
phase()->set_ctrl(xboi, pre_ctrl);
phase()->register_new_node(xboi, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(xboi);
}

Expand All @@ -3659,20 +3649,19 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() {
// When the base() is top, we have no alignment guarantee at all.
// Hence, we must now take the base into account for the calculation.
Node* xbase = new CastP2XNode(nullptr, base);
igvn().register_new_node_with_optimizer(xbase);
phase()->register_new_node(xbase, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(xbase);
#ifdef _LP64
xbase = new ConvL2INode(xbase);
igvn().register_new_node_with_optimizer(xbase);
phase()->register_new_node(xbase, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(xbase);
#endif
if (is_sub) {
xboi = new SubINode(xboi, xbase);
} else {
xboi = new AddINode(xboi, xbase);
}
igvn().register_new_node_with_optimizer(xboi);
phase()->set_ctrl(xboi, pre_ctrl);
phase()->register_new_node(xboi, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(xboi);
}

Expand All @@ -3681,8 +3670,7 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() {
// The division is executed as shift
Node* log2_abs_scale = igvn().intcon(exact_log2(abs(scale)));
Node* XBOI = new URShiftINode(xboi, log2_abs_scale);
igvn().register_new_node_with_optimizer(XBOI);
phase()->set_ctrl(XBOI, pre_ctrl);
phase()->register_new_node(XBOI, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(log2_abs_scale);
TRACE_ALIGN_VECTOR_NODE(XBOI);

Expand All @@ -3696,8 +3684,7 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() {
} else {
XBOI_OP_old_limit = new AddINode(XBOI, old_limit);
}
igvn().register_new_node_with_optimizer(XBOI_OP_old_limit);
phase()->set_ctrl(XBOI_OP_old_limit, pre_ctrl);
phase()->register_new_node(XBOI_OP_old_limit, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(XBOI_OP_old_limit);

// 3.2: Compute:
Expand All @@ -3708,8 +3695,7 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() {
// a bitmask operation.
Node* mask_AW = igvn().intcon(AW-1);
Node* adjust_pre_iter = new AndINode(XBOI_OP_old_limit, mask_AW);
igvn().register_new_node_with_optimizer(adjust_pre_iter);
phase()->set_ctrl(adjust_pre_iter, pre_ctrl);
phase()->register_new_node(adjust_pre_iter, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(mask_AW);
TRACE_ALIGN_VECTOR_NODE(adjust_pre_iter);

Expand All @@ -3722,17 +3708,15 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() {
} else {
new_limit = new AddINode(old_limit, adjust_pre_iter);
}
igvn().register_new_node_with_optimizer(new_limit);
phase()->set_ctrl(new_limit, pre_ctrl);
phase()->register_new_node(new_limit, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(new_limit);

// 5: Compute (15a, b):
// Prevent pre-loop from going past the original limit of the loop.
Node* constrained_limit =
(stride > 0) ? (Node*) new MinINode(new_limit, orig_limit)
: (Node*) new MaxINode(new_limit, orig_limit);
igvn().register_new_node_with_optimizer(constrained_limit);
phase()->set_ctrl(constrained_limit, pre_ctrl);
phase()->register_new_node(constrained_limit, pre_ctrl);
TRACE_ALIGN_VECTOR_NODE(constrained_limit);

// 6: Hack the pre-loop limit
Expand Down

1 comment on commit bfff02e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.