[llvm-commits] [llvm] r81634 - /llvm/trunk/lib/VMCore/ConstantsContext.h
Dan Gohman
gohman at apple.com
Sat Sep 12 15:02:17 PDT 2009
Author: djg
Date: Sat Sep 12 17:02:17 2009
New Revision: 81634
URL: http://llvm.org/viewvc/llvm-project?rev=81634&view=rev
Log:
Preserve the inbounds flag, so that the constant folder doesn't
recompute it.
Modified:
llvm/trunk/lib/VMCore/ConstantsContext.h
Modified: llvm/trunk/lib/VMCore/ConstantsContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantsContext.h?rev=81634&r1=81633&r2=81634&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantsContext.h (original)
+++ llvm/trunk/lib/VMCore/ConstantsContext.h Sat Sep 12 17:02:17 2009
@@ -437,8 +437,11 @@
case Instruction::GetElementPtr:
// Make everyone now use a constant of the new type...
std::vector<Value*> Idx(OldC->op_begin()+1, OldC->op_end());
- New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0),
- &Idx[0], Idx.size());
+ New = cast<GEPOperator>(OldC)->isInBounds() ?
+ ConstantExpr::getInBoundsGetElementPtrTy(NewTy, OldC->getOperand(0),
+ &Idx[0], Idx.size()) :
+ ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0),
+ &Idx[0], Idx.size());
break;
}
More information about the llvm-commits
mailing list