[llvm] r186592 - SLPVectorizer: Speedup isConsecutive by manually checking GEPs with multiple indices.
Nadav Rotem
nrotem at apple.com
Thu Jul 18 11:20:46 PDT 2013
Author: nadav
Date: Thu Jul 18 13:20:45 2013
New Revision: 186592
URL: http://llvm.org/viewvc/llvm-project?rev=186592&view=rev
Log:
SLPVectorizer: Speedup isConsecutive by manually checking GEPs with multiple indices.
This brings the compile time of the SLP-Vectorizer to about 2.5% of OPT for my testcase.
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=186592&r1=186591&r2=186592&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Thu Jul 18 13:20:45 2013
@@ -1006,12 +1006,20 @@ bool BoUpSLP::isConsecutiveAccess(Value
GepB->accumulateConstantOffset(*DL, OffsetB))
return ((OffsetB.getSExtValue() - OffsetA.getSExtValue()) == Sz);
+ if (GepA->getNumIndices() != GepB->getNumIndices())
+ return false;
+
// Try to strip the geps. This makes SCEV faster.
- if (GepA->getNumIndices() == 1 && GepB->getNumIndices() == 1) {
- PtrA = GepA->getOperand(1);
- PtrB = GepB->getOperand(1);
- Sz = 1;
+ // Make sure that all of the indices except for the last are identical.
+ int LastIdx = GepA->getNumIndices();
+ for (int i = 0; i < LastIdx - 1; i++) {
+ if (GepA->getOperand(i+1) != GepB->getOperand(i+1))
+ return false;
}
+
+ PtrA = GepA->getOperand(LastIdx);
+ PtrB = GepB->getOperand(LastIdx);
+ Sz = 1;
}
// Check if PtrA is the base and PtrB is a constant offset.
More information about the llvm-commits
mailing list