diff options
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index ee5611ea7d..db8cc4487c 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -157,7 +157,8 @@ Constant *ConstantFoldGetElementPtr(const Constant *C, // To: int* getelementptr ([3 x int]* %X, long 0, long 0) // if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) - if (CE->getOpcode() == Instruction::Cast && IdxList.size() > 1) + if (CE->getOpcode() == Instruction::Cast && IdxList.size() > 1 && + IdxList[0]->isNullValue()) if (const PointerType *SPT = dyn_cast<PointerType>(CE->getOperand(0)->getType())) if (const ArrayType *SAT = dyn_cast<ArrayType>(SPT->getElementType())) |