On Fri, 3 Apr 2026 08:15:40 GMT, Xiaohong Gong <[email protected]> wrote:
>> src/hotspot/cpu/aarch64/aarch64.ad line 2692:
>>
>>> 2690: Node* u = n->unique_out();
>>> 2691: if (u->Opcode() == Op_AndVMask) {
>>> 2692: return true;
>>
>> Suggestion:
>>
>> // Check whether n is only used by an AndVMask node.
>> return n->outcnt() == 1 && n->unique_out() == Op_AndVMask;
>>
>>
>> Then you hardly even need a comment.
>
> Hi @theRealAph , I can add more strict condition to clone the `maskAll` node
> here, like:
>
> static bool is_vector_mask_bitwise_andnot_pattern(Node* n, Node* m) {
> if (n == nullptr || m == nullptr) {
> return false;
> }
>
> if (n->Opcode() == Op_XorVMask &&
> VectorNode::is_all_ones_vector(m)) {
> if (n->outcnt() > 1 || n->unique_out()->Opcode() != Op_AndVMask) {
> return false;
> }
> // Another input of the AndVMask should not be a bitwise not pattern.
> Node* andVMask = n->unique_out();
> Node* other_input = andVMask->in(1) == n ? andVMask->in(2) :
> andVMask->in(1);
> return !(VectorNode::is_vectormask_bitwise_not_pattern(other_input) &&
> other_input->outcnt() == 1);
> }
> return false;
> }
>
> The advantage of this approach is that we can ensure maskAll itself is never
> cloned, whereas the downside is that the andNot rule can not be matched
> successfully.
>
> There may be other ways to make these rules match together without generating
> duplicate machnodes. For example, we could clone a dedicated maskAll at the
> IR level for this specific pattern during the final reshaping stage. However,
> this feels more like a workaround to satisfy backend match rules, and I am
> not sure whether it is an appropriate solution.
>
> Do you have any suggestions or best practices for handling this kind of
> situation?
>
> Hi @eme64 , @iwanowww , could I get any suggestions or ideas from your side?
Hi, I excluded the cases above by adding extra checks for cloning the
`all-ones-vector` mask node in the pattern. The node is not cloned if the other
input of the `AndVMask` is also a `mask-not` (with the same `all-ones-vector`
input) pattern. With this change, the SVE `andNot` rule will not be matched in
these cases, but the benefit is that we avoid generating duplicate `maskAll`
mach nodes for the pattern above. Please kindly review and share your feedback!
Thanks a lot!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30013#discussion_r3048829737