git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-05-14 02:47:13 +00:00
parent 7cb77e188f
commit e0c60038eb

View File

@ -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()))