From a08971559d6393307070ec970e35240eb0598deb Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 13 Jul 2007 22:50:48 +0000 Subject: [PATCH] Handle GEPs with all-zero indices in the same way we handle pointer-pointer bitcasts. Also, fix a potentia infinite loop. This brings FastDSE to parity with old DSE on 175.vpr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39839 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/FastDSE.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/FastDSE.cpp b/lib/Transforms/Scalar/FastDSE.cpp index 13e61366477..901a735e3c0 100644 --- a/lib/Transforms/Scalar/FastDSE.cpp +++ b/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