Keep ignoring pointer-to-pointer bitcasts
authorVictor Hernandez <vhernandez@apple.com>
Fri, 22 Jan 2010 19:05:05 +0000 (19:05 +0000)
committerVictor Hernandez <vhernandez@apple.com>
Fri, 22 Jan 2010 19:05:05 +0000 (19:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94194 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
lib/Transforms/Utils/PromoteMemoryToRegister.cpp

index 91219c45ad7dae73c57a3145e5fd5db150b566d9..ae728ddecfda927ef19751cbdb473faeac63ea4a 100644 (file)
@@ -406,8 +406,10 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
   for (unsigned ScanInsts = 6; BBI != SI.getParent()->begin() && ScanInsts;
        --ScanInsts) {
     --BBI;
-    // Don't count debug info directives, lest they affect codegen
-    if (isa<DbgInfoIntrinsic>(BBI)) {
+    // Don't count debug info directives, lest they affect codegen,
+    // and we skip pointer-to-pointer bitcasts, which are NOPs.
+    if (isa<DbgInfoIntrinsic>(BBI) ||
+        (isa<BitCastInst>(BBI) && isa<PointerType>(BBI->getType()))) {
       ScanInsts++;
       continue;
     }    
@@ -476,7 +478,8 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
   BBI = &SI; 
   do {
     ++BBI;
-  } while (isa<DbgInfoIntrinsic>(BBI));
+  } while (isa<DbgInfoIntrinsic>(BBI) ||
+           (isa<BitCastInst>(BBI) && isa<PointerType>(BBI->getType())));
   if (BranchInst *BI = dyn_cast<BranchInst>(BBI))
     if (BI->isUnconditional())
       if (SimplifyStoreAtEndOfBlock(SI))
@@ -536,7 +539,8 @@ bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) {
   if (OtherBr->isUnconditional()) {
     --BBI;
     // Skip over debugging info.
-    while (isa<DbgInfoIntrinsic>(BBI)) {
+    while (isa<DbgInfoIntrinsic>(BBI) ||
+           (isa<BitCastInst>(BBI) && isa<PointerType>(BBI->getType()))) {
       if (BBI==OtherBB->begin())
         return false;
       --BBI;
index 291d320636a850285a2f8165c14e783c08e5ac4d..9fdcfe5ec3ddda31ba7233484dc849198fdfccb5 100644 (file)
@@ -76,9 +76,6 @@ bool llvm::isAllocaPromotable(const AllocaInst *AI) {
         return false;   // Don't allow a store OF the AI, only INTO the AI.
       if (SI->isVolatile())
         return false;
-    } else if (isa<BitCastInst>(*UI)) {
-      // A bitcast inhibits promotion.
-      return false;
     } else {
       return false;
     }