On Tue, 8 Jul 2025 09:49:30 GMT, erifan <d...@openjdk.org> wrote: >> Thanks for your answers @erifan ! >> >> Can you please answer these as well? >> >>> predicate cannot be negated AND the vector is all ones. Can you explain >>> this condition? >> >> A code comment would be helpful for this case. I'm a little bit struggling >> to understand the bracket/negation here. >> >>> Why do you guard against VectorNode::is_all_ones_vector(in2) at all? >> >> Is this necessary? Why? > >> predicate cannot be negated AND the vector is all ones. Can you explain this >> condition? > > Ok, I'll add a comment for it. > >> Why do you guard against VectorNode::is_all_ones_vector(in2) at all? > > Because one of the nodes in the supported patterns by this PR needs to be > `MaskAll` or `Replicate`. And this function `VectorNode::is_all_ones_vector` > just meets our check for `MaskAll` and `Replicate`. Actually I don't quite > understand your question. I have two understandings: > 1. Not all nodes that `VectorNode::is_all_ones_vector` returns true are > `MaskAll` or `Replicate`, but other nodes that do not meet the conditions. > 2. Here, it does not need to be a vector with every bit 1, it only needs to > be an `all true` mask. > > Which one do you mean? Or something else? Thanks~
The purpose of this PR is optimizing the following kinds of patterns: XXXVector va, vb; va.compare(EQ, vb).not() And the generated IR of `va.compare(EQ, vb).not()` is `(XorVMask (VectorMaskCmp va vb EQ) (MaskAll -1))`. On platforms like aarch64 NEON, `MaskAll` is `Replicate`. And `MaskAll` and `Replicate` are both all ones vectors, so we do this check `VectorNode::is_all_ones_vector(in2)` ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24674#discussion_r2192087590