RFR: 8322490: CastNode constructors accepts control node as input

Christian Hagedorn chagedorn at openjdk.org
Wed Dec 20 07:44:48 UTC 2023


On Wed, 20 Dec 2023 07:39:31 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> It is a common pattern to have:
>> 
>> 
>> Node* n = new CastNode(...);
>> n->set_req(control_node);
>> 
>> 
>> We can modify the constructor to set the control node. It makes the code a little tidier.
>> 
>> Passes tier1 locally on my Linux machine
>
> src/hotspot/share/opto/castnode.cpp line 126:
> 
>> 124: }
>> 125: 
>> 126: Node* ConstraintCastNode::make_cast(int opcode, Node* c, Node* n, const Type* t, DependencyType dependency,
> 
> I'm wondering if this method is still worth keeping as it would simply replace a "new CastXXNode" line which is just as expressive/readable. As far as I can see, it's currently only used with statically known Opcodes. So, we could replace them.

On a separate note and might be worth to do in this change as well, we have `ConstraintCastNode::make_cast_for_type()` and `ConstraintCastNode::make()`. The intent of the former is clear but the latter switches on the provided basic type. Maybe we can rename the latter to `make_cast_for_basic_type()` to better align it with `make_cast_for_type()`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17162#discussion_r1432359469


More information about the hotspot-compiler-dev mailing list