summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorMichael Liao <michael.hliao@gmail.com>2019-07-16 01:03:06 +0000
committerMichael Liao <michael.hliao@gmail.com>2019-07-16 01:03:06 +0000
commit543ba4e9e0c421bedaea2d8a0f1965092cec300e (patch)
treeff8bc9aac9e51b287e4865863e1099cf2f3096c2 /llvm/lib/Analysis/InstructionSimplify.cpp
parent0d121273181f89b5296b02084fbb967d159b2c69 (diff)
downloadbcm5719-llvm-543ba4e9e0c421bedaea2d8a0f1965092cec300e.tar.gz
bcm5719-llvm-543ba4e9e0c421bedaea2d8a0f1965092cec300e.zip
[InstructionSimplify] Apply sext/trunc after pointer stripping
Summary: - As the pointer stripping could trace through `addrspacecast` now, need to sext/trunc the offset to ensure it has the same width as the pointer after stripping. Reviewers: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64768 llvm-svn: 366162
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index c0d69f9275d..e34bf6f4e43 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -660,6 +660,10 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout &DL, Value *&V,
APInt Offset = APInt::getNullValue(IntPtrTy->getIntegerBitWidth());
V = V->stripAndAccumulateConstantOffsets(DL, Offset, AllowNonInbounds);
+ // As that strip may trace through `addrspacecast`, need to sext or trunc
+ // the offset calculated.
+ IntPtrTy = DL.getIntPtrType(V->getType())->getScalarType();
+ Offset = Offset.sextOrTrunc(IntPtrTy->getIntegerBitWidth());
Constant *OffsetIntPtr = ConstantInt::get(IntPtrTy, Offset);
if (V->getType()->isVectorTy())
OpenPOWER on IntegriCloud