diff options
Diffstat (limited to 'llvm/lib/VMCore/ConstantHandling.cpp')
| -rw-r--r-- | llvm/lib/VMCore/ConstantHandling.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp index ee5611ea7de..db8cc4487c1 100644 --- a/llvm/lib/VMCore/ConstantHandling.cpp +++ b/llvm/lib/VMCore/ConstantHandling.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())) |

