aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-07-16 22:51:07 +0000
committerNadav Rotem <nrotem@apple.com>2013-07-16 22:51:07 +0000
commit7c8a26030faad65d49ecd06a4e51344368b79d8d (patch)
tree842ea378128a3f72e11f954c9aa57a5b73fa78b7 /lib/Transforms
parent82d4215f64dc941f21bbae7ec781367d343387b8 (diff)
downloadexternal_llvm-7c8a26030faad65d49ecd06a4e51344368b79d8d.zip
external_llvm-7c8a26030faad65d49ecd06a4e51344368b79d8d.tar.gz
external_llvm-7c8a26030faad65d49ecd06a4e51344368b79d8d.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Vectorize/SLPVectorizer.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 50ca697..c1e8111 100644
--- a/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -983,6 +983,24 @@ bool BoUpSLP::isConsecutiveAccess(Value *A, Value *B) {
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);