fix PR4848 an infinite loop when indexing down through a recursive gep
and we get the original pointer type. This doesn't mean that we're
at the first pointer being indexed. Correct the predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80762 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 5dcb021..109eaad 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -172,7 +172,7 @@
do {
if (const SequentialType *ATy = dyn_cast<SequentialType>(Ty)) {
// The only pointer indexing we'll do is on the first index of the GEP.
- if (isa<PointerType>(ATy) && ATy != Ptr->getType())
+ if (isa<PointerType>(ATy) && !NewIdxs.empty())
break;
// Determine which element of the array the offset points into.
APInt ElemSize(BitWidth, TD->getTypeAllocSize(ATy->getElementType()));