[PATCH] D14829: [SLP] Vectorize gather-like idioms ending at non-consecutive loads.

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 10:02:51 PST 2015


mssimpso created this revision.
mssimpso added reviewers: nadav, jmolloy, hfinkel.
mssimpso added subscribers: llvm-commits, mcrosier.

This patch tries to vectorize gather-like expression trees ending at
non-consecutive loads, such as the one shown in the example below.

```
... = g[a[0] - b[0]] + g[a[1] - b[1]] + ... + g[a[n] - b[n]];
```

Here, the index calculations for the "g" accesses can be vectorized. The loads
of the "a" and "b" array elements and the subtractions can all be replaced by
their vector equivalents. Our bottom-up vectorizer currently misses cases like
this because the expression trees don't end in stores or reductions.

It's possible to vectorize these cases in a top-down phase beginning at the
consecutive loads. However, I've chosen here to detect the specific pattern of
interest and proceed bottom-up as we do with other interesting cases. The
advantage of this approach is that it avoids the complexity, compile-time, and
phase ordering issues of a full-blown top-down pass. The disadvantage is that
it's probably not as general as it would be otherwise.

The primary changes included in the patch allow us to (1) vectorize the
gather-like pattern shown above and (2) set vector factors based on the width
of memory accesses in the expression trees. Your feedback is welcome.

http://reviews.llvm.org/D14829

Files:
  lib/Transforms/Vectorize/SLPVectorizer.cpp
  test/Transforms/SLPVectorizer/AArch64/gather-reduce.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14829.40672.patch
Type: text/x-patch
Size: 22987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151119/803f1c9a/attachment.bin>


More information about the llvm-commits mailing list