Handle GEPs with all-zero indices in the same way we handle pointer-pointer bitcasts...
authorOwen Anderson <resistor@mac.com>
Fri, 13 Jul 2007 22:50:48 +0000 (22:50 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 13 Jul 2007 22:50:48 +0000 (22:50 +0000)
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

index 13e6136647732894d8b8a9ced0a3e25e9ebf20f0..901a735e3c0b899f9a43d7f4a725063d586f1719 100644 (file)
@@ -60,9 +60,18 @@ namespace {
       assert(isa<PointerType>(v->getType()) && "Translating a non-pointer type?");
       
       // See through pointer-to-pointer bitcasts
-      while (BitCastInst* C = dyn_cast<BitCastInst>(v))
-        if (isa<PointerType>(C->getSrcTy()))
-          v = C->getOperand(0);
+      while (isa<BitCastInst>(v) || isa<GetElementPtrInst>(v))
+        if (BitCastInst* C = dyn_cast<BitCastInst>(v)) {
+          if (isa<PointerType>(C->getSrcTy()))
+            v = C->getOperand(0);
+          else
+            break;
+        } else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(v)) {
+          if (G->hasAllZeroIndices())
+            v = G->getOperand(0);
+          else
+            break;
+        }
     }
 
     // getAnalysisUsage - We require post dominance frontiers (aka Control