Fix bug: test/Regression/Transforms/InstCombine/2002-09-17-GetElementPtrCrash.ll

Thanks to Casey for finding it!

llvm-svn: 3783
This commit is contained in:
Chris Lattner 2002-09-17 21:05:42 +00:00
parent 0822dd0210
commit a8339e3613
1 changed files with 2 additions and 1 deletions

View File

@ -669,7 +669,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
*cast<Constant>(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());