[PATCH] D67510: [LV] Support gaps, overlaps, and inexact sizes in speculation logic

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 14:16:19 PDT 2019


Ayal added inline comments.


================
Comment at: lib/Analysis/Loads.cpp:224
     return false;
-  // TODO: generalize to access patterns which have gaps
-  if (Step->getAPInt() != EltSize)
-    return false;
+  APInt StepC = Step->getAPInt();
 
----------------
Note that StepC may be negative; LV can vectorize accesses such as A[N-i], and also group together accesses with negative non-unit stride into "reversed" interleave groups.


================
Comment at: lib/Analysis/Loads.cpp:226
 
-  // TODO: If the symbolic trip count has a small bound (max count), we might
-  // be able to prove safety.
-  auto TC = SE.getSmallConstantTripCount(L);
-  if (!TC)
-    return false;
+  // Use the exact trip count if we can compute one; if we can't, try the an
+  // upper bound (which forces us to prove a wider range is dereferenceable
----------------
try [the] an


================
Comment at: lib/Analysis/Loads.cpp:228
+  // upper bound (which forces us to prove a wider range is dereferenceable
+  // then is actually required if we knew the precise trip count.) 
+  unsigned TC = SE.getSmallConstantTripCount(L);
----------------
then > than


================
Comment at: lib/Analysis/Loads.cpp:242
+  //   load i32, i32* <0,+,2>, align 2 (every 2 bytes, load a 4 byte chunk)
+  const APInt AccessSize = (TC-1) * StepC + EltSize;
 
----------------
Note that interleave groups (of loads with positive step currently) with gaps at the end may benefit from checking dereferenceability across AccessSize of TC * StepC. But that warrants a separate patch.


================
Comment at: lib/Analysis/Loads.cpp:252
+  // the address at each iteration is aligned.  (Note: Alignment may be less
+  // tha element size.)
+  if (StepC.urem(Align) != 0)
----------------
tha[n]


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67510





More information about the llvm-commits mailing list