From dfcbf012226c17faba2bfc2f967ac2496fb98238 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Sep 2002 21:05:42 +0000 Subject: [PATCH] Fix bug: test/Regression/Transforms/InstCombine/2002-09-17-GetElementPtrCrash.ll Thanks to Casey for finding it! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3783 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 179f3b296ab..082dc020b00 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -669,7 +669,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { *cast(GEP.getOperand(1)); assert(Indices[0] != 0 && "Constant folding of uint's failed!?"); - } else if (*GEP.idx_begin() == ConstantUInt::getNullValue(Type::LongTy)) { + } else if (*GEP.idx_begin() == ConstantUInt::getNullValue(Type::LongTy) && + Src->getNumOperands() != 1) { // Otherwise we can do the fold if the first index of the GEP is a zero Indices.insert(Indices.end(), Src->idx_begin(), Src->idx_end()); Indices.insert(Indices.end(), GEP.idx_begin()+1, GEP.idx_end());