aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-07-13 15:53:46 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-07-13 15:53:46 +0000
commit4cff2f8d49dc65a1a7dc220c6df54f526f967441 (patch)
tree17e5d7a4f8df629e7ecc26f162571622b1f37b6a /llvm/lib/Analysis/ConstantFolding.cpp
parenta99368fa3540a82fd6aaf125a63a8b5c3b0674aa (diff)
downloadllvm-4cff2f8d49dc65a1a7dc220c6df54f526f967441.zip
llvm-4cff2f8d49dc65a1a7dc220c6df54f526f967441.tar.gz
llvm-4cff2f8d49dc65a1a7dc220c6df54f526f967441.tar.bz2
[ConstantFolding] Use sdiv_ov
This is a simplification, there should be no functional change. llvm-svn: 275273
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 20370d2..73bdd99 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -850,13 +850,13 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
// index for this level and proceed to the next level to see if it can
// accommodate the offset.
NewIdxs.push_back(ConstantInt::get(IntPtrTy, 0));
- } else if (ElemSize.isAllOnesValue()) {
- // Avoid signed overflow.
- break;
} else {
// The element size is non-zero divide the offset by the element
// size (rounding down), to compute the index at this level.
- APInt NewIdx = Offset.sdiv(ElemSize);
+ bool Overflow;
+ APInt NewIdx = Offset.sdiv_ov(ElemSize, Overflow);
+ if (Overflow)
+ break;
Offset -= NewIdx * ElemSize;
NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));
}