summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorMichael Liao <michael.hliao@gmail.com>2019-07-18 17:30:27 +0000
committerMichael Liao <michael.hliao@gmail.com>2019-07-18 17:30:27 +0000
commit17a8a9277c11e41792c53c1513f3e787d66f3c76 (patch)
tree3c46f3ce1d0b765c0a5daea9aa934f5a69ff8719 /llvm/lib/Analysis
parent2e97a1e19ef5492a409d206bb544a746cd26360d (diff)
downloadbcm5719-llvm-17a8a9277c11e41792c53c1513f3e787d66f3c76.tar.gz
bcm5719-llvm-17a8a9277c11e41792c53c1513f3e787d66f3c76.zip
[LAA] Re-check bit-width of pointers after stripping.
Summary: - As the pointer stripping now tracks through `addrspacecast`, prepare to handle the bit-width difference from the result pointer. Reviewers: jdoerfert Subscribers: jvesely, nhaehnle, hiraditya, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64928 llvm-svn: 366470
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 36bd9a8b7ea..31afecbaa5e 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1189,12 +1189,25 @@ bool llvm::isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL,
unsigned IdxWidth = DL.getIndexSizeInBits(ASA);
Type *Ty = cast<PointerType>(PtrA->getType())->getElementType();
- APInt Size(IdxWidth, DL.getTypeStoreSize(Ty));
APInt OffsetA(IdxWidth, 0), OffsetB(IdxWidth, 0);
PtrA = PtrA->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetA);
PtrB = PtrB->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetB);
+ // Retrieve the address space again as pointer stripping now tracks through
+ // `addrspacecast`.
+ ASA = cast<PointerType>(PtrA->getType())->getAddressSpace();
+ ASB = cast<PointerType>(PtrB->getType())->getAddressSpace();
+ // Check that the address spaces match and that the pointers are valid.
+ if (ASA != ASB)
+ return false;
+
+ IdxWidth = DL.getIndexSizeInBits(ASA);
+ OffsetA = OffsetA.sextOrTrunc(IdxWidth);
+ OffsetB = OffsetB.sextOrTrunc(IdxWidth);
+
+ APInt Size(IdxWidth, DL.getTypeStoreSize(Ty));
+
// OffsetDelta = OffsetB - OffsetA;
const SCEV *OffsetSCEVA = SE.getConstant(OffsetA);
const SCEV *OffsetSCEVB = SE.getConstant(OffsetB);
OpenPOWER on IntegriCloud