[PATCH] D23646: Generalize strided store pattern in interleave access pass
Matthew Simpson via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 10:42:49 PDT 2016
mssimpso added inline comments.
================
Comment at: lib/CodeGen/InterleavedAccessPass.cpp:159-164
@@ -158,8 +158,8 @@
/// \brief Check if the mask is RE-interleave mask for an interleaved store.
///
/// I.e. <0, NumSubElts, ... , NumSubElts*(Factor - 1), 1, NumSubElts + 1, ...>
///
/// E.g. The RE-interleave mask (Factor = 2) could be:
/// <0, 4, 1, 5, 2, 6, 3, 7>
static bool isReInterleaveMask(ArrayRef<int> Mask, unsigned &Factor) {
----------------
You should probably update this to define the more general pattern.
================
Comment at: lib/CodeGen/InterleavedAccessPass.cpp:181-207
@@ -180,8 +180,29 @@
// elements.
- unsigned i = 0;
- for (; i < NumElts; i++)
- if (Mask[i] >= 0 &&
- static_cast<unsigned>(Mask[i]) !=
- (i % Factor) * NumSubElts + i / Factor)
+ unsigned i = 0, j;
+ for (; i < Factor; i++) {
+ int PreviousMask = -1;
+ int PreviousPos = -1;
+ //TODO: check that Mask[i] (if it exists) is aligned (TLI).
+ //TODO: add additional tests (+ARM)
+ for (j = 0; j < NumSubElts-1; j++) {
+ unsigned ij = j*Factor + i;
+ if (Mask[ij] >= 0 && Mask[ij + Factor] >= 0 &&
+ static_cast<unsigned>(Mask[ij]) + 1 !=
+ static_cast<unsigned>(Mask[ij + Factor]))
+ break;
+
+ // With undefined mask, we can have: 2, undef, 7, undef, 32.
+ // Compare the next mask, with value from further back to avoid this.
+ if (PreviousMask > 0 && Mask[ij] < 0 && Mask[ij + Factor] >= 0 &&
+ static_cast<unsigned>(PreviousMask) + (j - PreviousPos) + 1 !=
+ static_cast<unsigned>(Mask[ij + Factor]))
+ break;
+ if (Mask[ij] >= 0 && Mask[ij + Factor] < 0) {
+ PreviousMask = Mask[ij];
+ PreviousPos = j;
+ }
+ }
+ if (j < NumSubElts-1)
break;
+ }
----------------
This looks fairly reasonable to me, but the parts dealing with undef are pretty difficult to follow. I think some more high-level comments would help people better understand what's going on here.
https://reviews.llvm.org/D23646
More information about the llvm-commits
mailing list