Preserve the inbounds flag, so that the constant folder doesn't
authorDan Gohman <gohman@apple.com>
Sat, 12 Sep 2009 22:02:17 +0000 (22:02 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 12 Sep 2009 22:02:17 +0000 (22:02 +0000)
recompute it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81634 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantsContext.h

index 9785d377b26433d39200efe033c8d16234417739..4f55502ff94825c029bbcc27c7f16624e7340eb2 100644 (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;
     }