[PATCH] D67645: [aarch64] add def-pats for dot product

Sebastian Pop via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 11:58:18 PDT 2019


sebpop added a comment.

In D67645#1674197 <https://reviews.llvm.org/D67645#1674197>, @az wrote:

> There are few things missing in current work such as indexed dot product or what they call s/udot (vector, by element) in the ARM document (no need to do it now but a comment about that would help).


I added a comment in the patch.

> There is also sve dot product. We need to port this code to SVE.

Same here, I added a FIXME comment.

> I agree that this work will miss many opportunities and the middle end will optimize the code in such a way that pattern matching does not work. I think that dot product need to have it own pass or subpass in the middle end. I see three places where it can be done: 1) early before the vectorizer in the same way we recognize min/max/etc., or 2) we can do it within the vectorizer as dot product is mainly a vectorization problem, or 3) we can do it post the vectorizer similar to the SIMD interleaved load/store. The third option, while not the best, has more chance of being accepted given that it less disruptive. Any tought on this as we may contribute to this effort in the future?

I think I like your solution 2, and I think pre and post vectorizer passes would work as well.

In the SnapDragon compiler we used to generate ARM builtins/intrinsics directly from the vectorizer:
that way we didn't spend time in the back-end to select again instructions and
it provided a mechanism to ensure that the code generated by the vectorizer
looked the same in the back-end. That worked nicely.

Similarly, for the dot product we may want to generate a target independent builtin,
as LLVM does today for `@llvm.experimental.vector.reduce.add.v16i32` in
`llvm/lib/CodeGen/ExpandReductions.cpp`.
If the target has a special instruction to handle the dot product,
it will implement a custom lowering.
So there will be no need to recognize the dot product again
if the vectorizer has already done that work.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67645/new/

https://reviews.llvm.org/D67645





More information about the llvm-commits mailing list