diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-22 01:03:40 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-22 01:03:40 +0000 |
commit | 0a4fc46321681ea78265cb9415c242e84b45fe61 (patch) | |
tree | f70d689b65adaeff96d5e0546ca33c2d8bfbbc4a /llvm/lib/Analysis | |
parent | c4030a19379c88f899f343281f6eacd5caa0218f (diff) | |
download | bcm5719-llvm-0a4fc46321681ea78265cb9415c242e84b45fe61.tar.gz bcm5719-llvm-0a4fc46321681ea78265cb9415c242e84b45fe61.zip |
Analysis: gep inbounds (gep inbounds (...)) is inbounds.
Differential Revision: https://reviews.llvm.org/D26441
llvm-svn: 287604
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 69e2e8ad20f..500faed39b1 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -773,6 +773,7 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, const DataLayout &DL, const TargetLibraryInfo *TLI) { const GEPOperator *InnermostGEP = GEP; + bool InBounds = GEP->isInBounds(); Type *SrcElemTy = GEP->getSourceElementType(); Type *ResElemTy = GEP->getResultElementType(); @@ -825,6 +826,7 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, // If this is a GEP of a GEP, fold it all into a single GEP. while (auto *GEP = dyn_cast<GEPOperator>(Ptr)) { InnermostGEP = GEP; + InBounds &= GEP->isInBounds(); SmallVector<Value *, 4> NestedOps(GEP->op_begin() + 1, GEP->op_end()); @@ -946,8 +948,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, } // Create a GEP. - Constant *C = ConstantExpr::getGetElementPtr( - SrcElemTy, Ptr, NewIdxs, /*InBounds=*/false, InRangeIndex); + Constant *C = ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs, + InBounds, InRangeIndex); assert(C->getType()->getPointerElementType() == Ty && "Computed GetElementPtr has unexpected type!"); |