Combine
and (vector_shuffle<Z,...,Z> (insert_vector_elt undef, (xor X, -1), Z), undef), Y -> andnp (vector_shuffle<Z,...,Z> (insert_vector_elt undef, X, Z), undef), Y
Paths
| Differential D138521
[X86] Support ANDNP combine through vector_shuffle ClosedPublic Authored by e-kud on Nov 22 2022, 1:45 PM.
Details Summary Combine and (vector_shuffle<Z,...,Z> (insert_vector_elt undef, (xor X, -1), Z), undef), Y -> andnp (vector_shuffle<Z,...,Z> (insert_vector_elt undef, X, Z), undef), Y
Diff Detail
Event Timelinee-kud retitled this revision from [X86] Support ANDN combine through broadcast instructions to [X86] Support ANDNP combine through broadcast instructions with scalar input.Nov 23 2022, 8:45 AM
e-kud added a child revision: D138734: [X86] combine-and.ll - add test coverage for scalar broadcast.Nov 25 2022, 2:04 PM e-kud removed a child revision: D138734: [X86] combine-and.ll - add test coverage for scalar broadcast.Nov 28 2022, 3:14 PM e-kud added a parent revision: D138734: [X86] combine-and.ll - add test coverage for scalar broadcast.Nov 28 2022, 3:48 PM This revision is now accepted and ready to land.Nov 28 2022, 11:27 PM
Comment Actions
Unfortunately, no. I only tested locally with 256 bits. I found out that the generic approach has a problem. If we have a 256 or 512 bit vector, then we can't generate ANDNP with SSE because there is no type for 256 bits. But after type-legalizer we have several ISD::AND that can be combined into ANDNP. I think about and (shuffle(not)) -> and(not(shuffle)) reordering before type-legalization and then after legalization we combine them into ANDNP. However I'm not sure about such two-step combine. What do you think? This revision now requires changes to proceed.Dec 10 2022, 11:09 AM e-kud edited parent revisions, added: D139991: [X86] combine-and.ll - add 256 and 512 bit test coverage for scalar broadcast; removed: D138734: [X86] combine-and.ll - add test coverage for scalar broadcast. Comment Actions LGTM with one minor comment - cheers
This revision is now accepted and ready to land.Dec 14 2022, 5:32 AM e-kud retitled this revision from [X86] Support ANDNP combine through broadcast instructions with scalar input to [X86] Support ANDNP combine through vector_shuffle.Dec 14 2022, 7:12 PM Closed by commit rG15dd5ed96cf1: [X86] Support ANDNP combine through vector_shuffle (authored by e-kud, committed by pengfei). · Explain WhyDec 22 2022, 1:30 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 484760 llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/combine-and.ll
|
You might need to bitcast this back to Src.getValueType() - its less likely for scalars but IsNOT can peek through bitcasts