diff options
author | Nadav Rotem <nrotem@apple.com> | 2013-07-19 23:11:15 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2013-07-19 23:11:15 +0000 |
commit | 5c9a193a65730848e48f0d8d0d52acf1a7dfd104 (patch) | |
tree | c792329c14a853b7345851f13c75f85ec4d2c097 /llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | |
parent | 98b20f1278e097f9f56b0c3bdb6740e230a47832 (diff) | |
download | bcm5719-llvm-5c9a193a65730848e48f0d8d0d52acf1a7dfd104.tar.gz bcm5719-llvm-5c9a193a65730848e48f0d8d0d52acf1a7dfd104.zip |
SLPVectorizer: Improve the compile time of isConsecutive by reordering the conditions that check GEPs and eliminate two of the calls to accumulateConstantOffset.
llvm-svn: 186731
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index f1da774ede5..42aa8a2b431 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -994,19 +994,27 @@ bool BoUpSLP::isConsecutiveAccess(Value *A, Value *B) { Type *Ty = cast<PointerType>(PtrA->getType())->getElementType(); int64_t Sz = DL->getTypeStoreSize(Ty); - // If both pointers are GEPs: - if (GepA && GepB) { - // Check that they have the same base pointer. - if (GepA->getPointerOperand() != GepB->getPointerOperand()) - return false; + // Check if PtrA is the base and PtrB is a constant offset. + if (GepB && GepB->getPointerOperand() == PtrA) { + APInt Offset(BW, 0); + if (GepB->accumulateConstantOffset(*DL, Offset)) + return Offset.getSExtValue() == Sz; + return false; + } - // Check if the geps use a constant offset. - APInt OffsetA(BW, 0) ,OffsetB(BW, 0); - if (GepA->accumulateConstantOffset(*DL, OffsetA) && - GepB->accumulateConstantOffset(*DL, OffsetB)) - return ((OffsetB.getSExtValue() - OffsetA.getSExtValue()) == Sz); + // Check if PtrB is the base and PtrA is a constant offset. + if (GepA && GepA->getPointerOperand() == PtrB) { + APInt Offset(BW, 0); + if (GepA->accumulateConstantOffset(*DL, Offset)) + return Offset.getSExtValue() == -Sz; + return false; + } - if (GepA->getNumIndices() != GepB->getNumIndices()) + // If both pointers are GEPs: + if (GepA && GepB) { + // Check that they have the same base pointer and number of indices. + if (GepA->getPointerOperand() != GepB->getPointerOperand() || + GepA->getNumIndices() != GepB->getNumIndices()) return false; // Try to strip the geps. This makes SCEV faster. @@ -1022,17 +1030,6 @@ bool BoUpSLP::isConsecutiveAccess(Value *A, Value *B) { Sz = 1; } - // Check if PtrA is the base and PtrB is a constant offset. - if (GepB && GepB->getPointerOperand() == PtrA) { - APInt Offset(BW, 0); - if (GepB->accumulateConstantOffset(*DL, Offset)) - return Offset.getZExtValue() == DL->getTypeStoreSize(Ty); - } - - // GepA can't use PtrB as a base pointer. - if (GepA && GepA->getPointerOperand() == PtrB) - return false; - ConstantInt *CA = dyn_cast<ConstantInt>(PtrA); ConstantInt *CB = dyn_cast<ConstantInt>(PtrB); if (CA && CB) { |