summaryrefslogtreecommitdiff
path: root/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2010-12-07 08:25:19 +0000
committerJay Foad <jay.foad@gmail.com>2010-12-07 08:25:19 +0000
commit40f8f6264d5af2c38e797e0dc59827cd231e8ff7 (patch)
tree3f3b576d6ec060c4063e4630d1ac4fad94997d82 /lib/Analysis/ConstantFolding.cpp
parent0ea112f104215ccba8d89c839cdeded6e3d49e59 (diff)
downloadllvm-40f8f6264d5af2c38e797e0dc59827cd231e8ff7.tar.gz
llvm-40f8f6264d5af2c38e797e0dc59827cd231e8ff7.tar.bz2
llvm-40f8f6264d5af2c38e797e0dc59827cd231e8ff7.tar.xz
PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ConstantFolding.cpp')
-rw-r--r--lib/Analysis/ConstantFolding.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 70ee9ddfa6..68a55b6b94 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -610,10 +610,8 @@ static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps,
APInt BasePtr(BitWidth, 0);
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr))
if (CE->getOpcode() == Instruction::IntToPtr)
- if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0))) {
- BasePtr = Base->getValue();
- BasePtr.zextOrTrunc(BitWidth);
- }
+ if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0)))
+ BasePtr = Base->getValue().zextOrTrunc(BitWidth);
if (Ptr->isNullValue() || BasePtr != 0) {
Constant *C = ConstantInt::get(Ptr->getContext(), Offset+BasePtr);
return ConstantExpr::getIntToPtr(C, ResultTy);