Preserve the inbounds flag, so that the constant folder doesn't

recompute it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81634 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-09-12 22:02:17 +00:00
parent 349a2ebbb3
commit 4acac62e8d

View File

@ -437,8 +437,11 @@ struct ConvertConstantType<ConstantExpr, Type> {
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;
}