[llvm] [AArch64] recognise zip1/zip2 with flipped operands (PR #167235)
Philip Ginsbach-Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 11:43:54 PST 2025
ginsbach wrote:
> > > I always though we were or should be canonicalising shuffles so that the first index is for the LHS.
> > > It is definitely possible to make clang -O2 -emit-llvm generate code where that is not the case (https://godbolt.org/z/Yx4TToebb):
>
> Yeah, it depends on the shuffle but many are not. I was wondering if we should - to avoid the need to try and match every pattern in multiple ways. It would fix them all at once, (and we could make the perfect shuffle tables smaller). There are DAG canonicalizations that get in the way though, for shuffle(x, shuffle), so this is probably OK.
Thank you for having another look!
I have implemented your two suggestions in commits 3 and 4.
I had to rebase and force-push due to minor merge conflicts with #167955 in three test cases (inside `@large` in `insert-extend.ll` and `@v1` and `@v2` in `reduce-shuffle.ll`).
I don't have the full context to comment on whether we should canonicalise more. However, it's worth noting that my initial motivation for this PR was the [interaction with the `slp-vectorizer`](https://github.com/llvm/llvm-project/issues/137447#issuecomment-3508719104) through `getShuffleCost`. So to fix that kind of use case we would have to canonicalise very early.
https://github.com/llvm/llvm-project/pull/167235
More information about the llvm-commits
mailing list