Cedric BAIL 3b62b61dc0
[WebAssembly] Fold vselect(cond, vnot(x), zero) to v128.andnot (#184949)
DAGCombiner canonicalizes `and(vnot(x), sext(cmp))` into `vselect(cmp,
vnot(x), zero)`. Without a dedicated ISel pattern, this falls through to
the generic vselect-to-bitselect lowering, producing `v128.not` +
`v128.bitselect`. This patch adds a higher-priority pattern that emits a
single `v128.andnot` instead, saving two instructions.

The direct `and(vnot(x), y)` pattern is already handled by the existing
`andnot` PatFrag. This patch covers the indirect path through
DAGCombiner's `and(x, sext(cmp))` → `vselect(cmp, x, zero)`
canonicalization, which obscures the `andnot` opportunity when `x` is
`vnot(y)`.


Assisted-by: Claude (Anthropic)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 17:34:59 +00:00
..