[PATCH] D25276: [LoopVectorizer] Interleaved-mem-accesses analysis and getPtrStride

silviu.baranga@arm.com via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 03:03:56 PDT 2016


sbaranga added a comment.

Yes, now that I think about it skipping case c) makes sense.



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5879
+    // that all the pointers in the group don't wrap.
+    Value *FirstMemberPtr = nullptr;
+    Value *LastMemberPtr = nullptr; 
----------------
FirstMemberPtr should always be getPointerOperand(Group->getMember(0)) (it's guaranteed to exist).

Now that I look at the code it would be simpler to go with a the more optimized version. It would be simpler to just go here with

  FirstMemberPtr = getPointerOperand(Group->getMember(0))
  LastMemberPtr = getPointerOperand(Group->getMember(Group->getFactor()-1))

and remove the loop. If we get null for LastMemberPtr we can just ignore it (since we know that in this case we will always peel the loop, meaning that we only need to check the first member). The code will look like:

if (!getPtrStride(PSE, FirstMemberPtr, TheLoop, Strides, 
                              /*Assume=*/false, /*ShouldCheckWrap=*/true)) {
  releaseGroup(Group);
  continue;
}

if (LastMemberPtr)
  if (!getPtrStride(PSE, LastMemberPtr, TheLoop, Strides, 
                              /*Assume=*/false, /*ShouldCheckWrap=*/true))) {
  releaseGroup();
  continue;
}


https://reviews.llvm.org/D25276





More information about the llvm-commits mailing list