diff --git a/llvm/lib/Transforms/Scalar/FastDSE.cpp b/llvm/lib/Transforms/Scalar/FastDSE.cpp index 13e613664773..901a735e3c0b 100644 --- a/llvm/lib/Transforms/Scalar/FastDSE.cpp +++ b/llvm/lib/Transforms/Scalar/FastDSE.cpp @@ -60,9 +60,18 @@ namespace { assert(isa(v->getType()) && "Translating a non-pointer type?"); // See through pointer-to-pointer bitcasts - while (BitCastInst* C = dyn_cast(v)) - if (isa(C->getSrcTy())) - v = C->getOperand(0); + while (isa(v) || isa(v)) + if (BitCastInst* C = dyn_cast(v)) { + if (isa(C->getSrcTy())) + v = C->getOperand(0); + else + break; + } else if (GetElementPtrInst* G = dyn_cast(v)) { + if (G->hasAllZeroIndices()) + v = G->getOperand(0); + else + break; + } } // getAnalysisUsage - We require post dominance frontiers (aka Control