On Fri, 6 Nov 2026 02:06:26 GMT, Quan Anh Mai <[email protected]> wrote:
>> Eric Fang has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Construct NodeOps with a PhaseGVN and revert make_con refactoring
>
> src/hotspot/share/opto/vectornode.cpp line 2947:
>
>> 2945:
>> 2946: // (XorV (AndV A B) B) => (AndV B (XorV A (Replicate -1)))
>> 2947: res = GenericOpts::Ideal_XorAnd_to_AndNot(this, phase);
>
> If you just call `GenericOpts::Ideal_XorAnd_to_AndNot<VECTOR>`, you don't
> have to implement `NodeType<NodeClass>` for all types of nodes anymore. What
> do you think?
Thanks, this is reasonable. We actually tried it before, but chose the current
approach because:
1. Every call site would have to pass `NodeTypeCon`, which is an implementation
detail of the callee. Since it can be deduced from `this`, passing both is
redundant. With deduction, a shared optimization is called like any other
function.
2. Deduction prevents mismatches. E.g. passing `<NodeTypeCon::VECTOR>` in
`XorVMaskNode::Ideal` would compile, and the optimization would silently not
apply.
We also tried dispatching at runtime on the node's type, but then every
optimization needs its own dispatching entry. e.g.:
Node* GenericOpts::Ideal_XorAnd_to_AndNot(Node* n, PhaseGVN* phase) {
if (n->bottom_type()->isa_pvectmask() != nullptr) {
return Ideal_XorAnd_to_AndNot_Impl<NodeTypeCon::PVECTMASK>(n, phase);
} else if (n->bottom_type()->isa_vect() != nullptr) {
return Ideal_XorAnd_to_AndNot_Impl<NodeTypeCon::VECTOR>(n, phase);
}
return nullptr;
}
The cost of the current approach is a `NodeType` specialization per root node
class, and one instantiation per node class rather than per `NodeTypeCon`. As
more optimizations are added, the number of specializations may grow
significantly, and some duplicate instantiation code.
I'm happy to switch if you have a better idea. Thanks~
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/32095#discussion_r4488783753