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

recompute it.

llvm-svn: 81634
This commit is contained in:
Dan Gohman 2009-09-12 22:02:17 +00:00
parent 07b5c40ed8
commit f436e87813
1 changed files with 5 additions and 2 deletions

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;
}