On Fri, 7 Aug 2026 05:46:37 GMT, Quan Anh Mai <[email protected]> wrote:

> Since these transformations are similar between different kinds of `XorNode` 
> (scalar, vector, mask). I suggest refactoring it to a separate function that 
> gets called from those places.

Thanks for the suggestion. Just to make sure I understand correctly: are you 
proposing that we extract the `(A & B) ^ B → ~A & B` rewrite into a shared 
helper and call it from scalar `XorI/XorL` as well as from vector/mask 
`XorV/XorVMask`?

If so, that is feasible for the pattern-matching part (finding the And, 
handling commutativity, checking single-use / TOP). I prototyped that briefly. 
The limitation is that constructing the rewritten graph does not share cleanly 
across these cases:

- scalar uses `XorI/L` + `AndI/L`

- vector/mask uses `Replicate/MaskAll` + `XorV/XorVMask` + `AndV/AndVMask`

- vector also needs extra checks that scalar does not (e.g. rejecting 
predicated `XorV/AndV`)

So beyond the matcher, each Ideal path still needs its own node-building glue, 
and folding scalar into this change would expand the scope (and tests) quite a 
bit.

I’d prefer to keep this RFE focused on the `vector/mask` canonicalize (which 
already shares one Ideal path for `XorV` and `XorVMask`), and file a follow-up 
RFE for the scalar side (and any further shared-helper cleanup) if that sounds 
reasonable to you.

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

PR Comment: https://git.openjdk.org/jdk/pull/32095#issuecomment-5213372170

Reply via email to