On Wed, 1 Apr 2026 07:59:01 GMT, Andrew Haley <[email protected]> wrote:
>> Xiaohong Gong has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Add comment
>
> 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.
When I address the comment above, I just realized that there is an issue if we
just checking whether `n` is only used by an `AndVMask` here. We should also
check another input of the `AndVMask`. Use below case as an example:
VectorMask vm1 = ...
VectorMask vm2 = ...
VectorMask vm3 = vm1.not().andNot(vm2);
The ideal graph will be:
vm1 MaskAll
\ |
\ /
\ /
XorVMask vm2 MaskAll
\ \ /
\ XorVMask
\ /
\ /
AndVMask
The two inputs of `AndVMask` are all the `not` pattern, and they are both only
used by the same `AndVMask`. Hence, the `MaskAll` will be cloned because the
condition in the method are all matched. However, only one of the `not` pattern
will be consumed by backend match rule (i.e. the `and_not` rule). Another `not`
is not matched and all the cloned `MaskAll` from its input will not be
consumed, still leading to the duplicated ptrue instructions. I can reproduce
this issue with a test locally. To fix this, we need to check another input of
`AndVMask`, and return true if it is not the `mask not` pattern. The shortage
is that the backend rule of `and_not` will not be matched finally. But it at
least would not increase the predicate register pressure.
I will fix this and add tests/benchmarks for this case.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30013#discussion_r3020850354