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

Arnold Schwaighofer aschwaighofer at apple.com
Tue May 5 14:48:39 PDT 2015


================
Comment at: lib/Analysis/LoopAccessAnalysis.cpp:804
@@ -795,2 +803,3 @@
+    MaxSafeDepDistBytes = Distance;
 
   bool IsTrueDataDependence = (!AIsWrite && BIsWrite);
----------------
MaxSafeDepDistBytes records the maximum distance that is still safe.

Say we saw a maximum safe distance of 4 bytes before. Now we process a new pair of access and the distance would be 8 bytes and that is still bigger-equal than "TypeByteSize * NumIterations * Stride". It is not correct to say our MaxSafeDepDistBytes is 8 bytes now.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3941
@@ +3940,3 @@
+
+    // Collect a list with consecutive accesses.
+    while (Tails.count(I) || Heads.count(I)) {
----------------
What does this code do if you have two interleaved accesses to the same location? (I know we should not see this in optimized IR, but we can't rely on this fact)


a[2i] = ; // (1)
a[2i] = ; // (2)
a[2i+1] = ; // (3)
a[2i+1] = ; // (4)


Are we guaranteed to get the pairs (1) (3) and (2)(4)?

It seems to me that we will get the last consecutive location since we process 'Queue' front to back in the loop above that populates ConsecutiveChain; in my example we would get (1), (4)

http://reviews.llvm.org/D9368

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list