Fix bug: test/Regression/Transforms/InstCombine/2002-09-17-GetElementPtrCrash.ll
authorChris Lattner <sabre@nondot.org>
Tue, 17 Sep 2002 21:05:42 +0000 (21:05 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Sep 2002 21:05:42 +0000 (21:05 +0000)
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

index 179f3b296ab080650b3f8584a6335f572ad8b296..082dc020b00900293e71c4968e70e5e06ff9da10 100644 (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());