[PATCH] [LoopVectorize]Teach Loop Vectorizer about interleaved memory access

Hao Liu Hao.Liu at arm.com
Mon May 25 03:31:26 PDT 2015

Updated a new patch refactored according to Michael and Adam.
There are two main changes:

  (1) Add a threshold MaxInterleaveStride to avoid analyzing accesses with too large stride.
  (2) Move the code about analyzing interleaved accesses in LoopAccessAnalysis to LoopVectorizer. 

Review please.


Comment at: test/Transforms/LoopVectorize/interleaved-accesses.ll:1
@@ +1,2 @@
+; RUN: opt -S -loop-vectorize -instcombine -force-vector-width=4 -force-vector-interleave=1 -enable-interleaving=true -runtime-memory-check-threshold=24 < %s | FileCheck %s
mzolotukhin wrote:
> HaoLiu wrote:
> > mzolotukhin wrote:
> > > Is it possible to use `noalias` attributes for arguments and drop `-runtime-memory-check-threshold=24`?
> > Hi Michael,
> > 
> > Do you mean by adding "-scoped-noalias". I tried but it doesn't work. I think maybe the runtime check is different from normal alias analysis.
> > 
> > 
> No, I meant changing declaration from this:
> ```
> define void @foo(%struct.ST2* nocapture readonly %A, %struct.ST2* nocapture %B)
> ```
> to
> ```
> define void @foo(%struct.ST2* noalias nocapture readonly %A, %struct.ST2* noalias nocapture %B)
> ```
> It'll tell that `A` and `B` don't alias, and thus we won't need runtime checks for them.
I tried this, but it still can not work for some cases like @test_struct_store4. It is a known problem with our runtime memory checks. It will check the dependences in the same array.
E.g. for (i = 0; i < n; i+=4) {
         A[i] = a;
         A[i+1] = b;
         A[i+2] = c;
         A[i+3] = d;
A lot of runtime checks with be generated for pairs in {A[i], A[i+1], A[i+2], A[i+3]} and will break the threshold.



More information about the llvm-commits mailing list