8334647: C2: CastII added by PhaseIdealLoop::add_template_assertion_predicate() should have control

Reviewed-by: chagedorn, kvn
This commit is contained in:
Roland Westrelin 2024-07-25 15:45:41 +00:00
parent 34ee06f511
commit f61a505989
5 changed files with 14 additions and 11 deletions

View File

@ -101,12 +101,9 @@ class CastIINode: public ConstraintCastNode {
virtual uint size_of() const;
public:
CastIINode(Node* n, const Type* t, DependencyType dependency = RegularDependency, bool range_check_dependency = false, const TypeTuple* types = nullptr)
: ConstraintCastNode(nullptr, n, t, dependency, types), _range_check_dependency(range_check_dependency) {
init_class_id(Class_CastII);
}
CastIINode(Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, bool range_check_dependency = false, const TypeTuple* types = nullptr)
: ConstraintCastNode(ctrl, n, t, dependency, types), _range_check_dependency(range_check_dependency) {
assert(ctrl != nullptr, "control must be set");
init_class_id(Class_CastII);
}
virtual int Opcode() const;
@ -134,6 +131,7 @@ class CastLLNode: public ConstraintCastNode {
public:
CastLLNode(Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr)
: ConstraintCastNode(ctrl, n, t, dependency, types) {
assert(ctrl != nullptr, "control must be set");
init_class_id(Class_CastLL);
}
@ -147,6 +145,7 @@ class CastFFNode: public ConstraintCastNode {
public:
CastFFNode(Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr)
: ConstraintCastNode(ctrl, n, t, dependency, types) {
assert(ctrl != nullptr, "control must be set");
init_class_id(Class_CastFF);
}
virtual int Opcode() const;
@ -157,6 +156,7 @@ class CastDDNode: public ConstraintCastNode {
public:
CastDDNode(Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr)
: ConstraintCastNode(ctrl, n, t, dependency, types) {
assert(ctrl != nullptr, "control must be set");
init_class_id(Class_CastDD);
}
virtual int Opcode() const;
@ -167,6 +167,7 @@ class CastVVNode: public ConstraintCastNode {
public:
CastVVNode(Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr)
: ConstraintCastNode(ctrl, n, t, dependency, types) {
assert(ctrl != nullptr, "control must be set");
init_class_id(Class_CastVV);
}
virtual int Opcode() const;
@ -192,6 +193,7 @@ class CheckCastPPNode: public ConstraintCastNode {
public:
CheckCastPPNode(Node* ctrl, Node* n, const Type* t, DependencyType dependency = RegularDependency, const TypeTuple* types = nullptr)
: ConstraintCastNode(ctrl, n, t, dependency, types) {
assert(ctrl != nullptr, "control must be set");
init_class_id(Class_CheckCastPP);
}

View File

@ -1341,8 +1341,8 @@ IfTrueNode* PhaseIdealLoop::add_template_assertion_predicate(IfNode* iff, IdealL
// init + (current stride - initial stride) is within the loop so narrow its type by leveraging the type of the iv Phi
const Type* type_iv = loop->_head->as_CountedLoop()->phi()->bottom_type();
assert(!type_iv->is_int()->is_con(), "constant indicates one loop iteration for which we bailed out earlier");
max_value = new CastIINode(max_value, type_iv);
register_new_node(max_value, parse_predicate_proj);
max_value = new CastIINode(new_proj, max_value, type_iv);
register_new_node(max_value, new_proj);
bol = rc_predicate(new_proj, scale, offset, max_value, limit, stride, rng, (stride > 0) != (scale > 0),
overflow);

View File

@ -3028,7 +3028,7 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) {
max_value = new AddINode(opaque_init, max_value);
register_new_node(max_value, loop_entry);
// init + (current stride - initial stride) is within the loop so narrow its type by leveraging the type of the iv Phi
max_value = new CastIINode(max_value, loop->_head->as_CountedLoop()->phi()->bottom_type());
max_value = new CastIINode(loop_entry, max_value, loop->_head->as_CountedLoop()->phi()->bottom_type());
register_new_node(max_value, loop_entry);
loop_entry = add_range_check_elimination_assertion_predicate(
loop, loop_entry, scale_con, int_offset, int_limit, stride_con, max_value, true

View File

@ -4670,6 +4670,9 @@ void DataNodeGraph::clone(Node* node, Node* new_ctrl) {
_phase->igvn().register_new_node_with_optimizer(clone);
_orig_to_new.put(node, clone);
_phase->set_ctrl(clone, new_ctrl);
if (node->is_CastII()) {
clone->set_req(0, new_ctrl);
}
}
// Rewire the data inputs of all (unprocessed) cloned nodes, whose inputs are still pointing to the same inputs as their

View File

@ -2484,12 +2484,10 @@ bool LibraryCallKit::inline_vector_insert() {
// Convert insert value back to its appropriate type.
switch (elem_bt) {
case T_BYTE:
insert_val = gvn().transform(new ConvL2INode(insert_val));
insert_val = gvn().transform(new CastIINode(insert_val, TypeInt::BYTE));
insert_val = gvn().transform(new ConvL2INode(insert_val, TypeInt::BYTE));
break;
case T_SHORT:
insert_val = gvn().transform(new ConvL2INode(insert_val));
insert_val = gvn().transform(new CastIINode(insert_val, TypeInt::SHORT));
insert_val = gvn().transform(new ConvL2INode(insert_val, TypeInt::SHORT));
break;
case T_INT:
insert_val = gvn().transform(new ConvL2INode(insert_val));