[llvm] r186465 - SLPVectorizer: Improve the compile time of isConsecutive by adding a simple constant-gep check before using SCEV.
Nadav Rotem
nrotem at apple.com
Tue Jul 16 15:51:07 PDT 2013
Author: nadav
Date: Tue Jul 16 17:51:07 2013
New Revision: 186465
URL: http://llvm.org/viewvc/llvm-project?rev=186465&view=rev
Log:
SLPVectorizer: Improve the compile time of isConsecutive by adding a simple constant-gep check before using SCEV.
This check does not always work because not all of the GEPs use a constant offset, but it happens often enough to reduce the number of times we use SCEV.
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=186465&r1=186464&r2=186465&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Tue Jul 16 17:51:07 2013
@@ -983,6 +983,24 @@ bool BoUpSLP::isConsecutiveAccess(Value
if (PtrA->getType() != PtrB->getType())
return false;
+ // Calculate a constant offset from the base pointer without using SCEV
+ // in the supported cases.
+ // TODO: Add support for the case where one of the pointers is a GEP that
+ // uses the other pointer.
+ GetElementPtrInst *GepA = dyn_cast<GetElementPtrInst>(PtrA);
+ GetElementPtrInst *GepB = dyn_cast<GetElementPtrInst>(PtrB);
+ if (GepA && GepB && GepA->getPointerOperand() == GepB->getPointerOperand()) {
+ unsigned BW = DL->getPointerSizeInBits(ASA);
+ APInt OffsetA(BW, 0) ,OffsetB(BW, 0);
+
+ if (GepA->accumulateConstantOffset(*DL, OffsetA) &&
+ GepB->accumulateConstantOffset(*DL, OffsetB)) {
+ Type *Ty = cast<PointerType>(PtrA->getType())->getElementType();
+ int64_t Sz = DL->getTypeStoreSize(Ty);
+ return ((OffsetB.getSExtValue() - OffsetA.getSExtValue()) == Sz);
+ }
+ }
+
// Calculate the distance.
const SCEV *PtrSCEVA = SE->getSCEV(PtrA);
const SCEV *PtrSCEVB = SE->getSCEV(PtrB);
More information about the llvm-commits
mailing list