Do not reserve DOM check for GetElementPtrInst.
authorDevang Patel <dpatel@apple.com>
Tue, 25 Sep 2007 17:55:50 +0000 (17:55 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 25 Sep 2007 17:55:50 +0000 (17:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42306 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LICM.cpp

index f112ba8262063aaa4135afd4faea8e90bc73baa8..e461c887ea2b36afd56fffe608c7d5fc0a1039da 100644 (file)
@@ -811,30 +811,31 @@ void LICM::FindPromotableValuesInLoop(
         // condition which may not yet folded.
         if (isa<ConstantPointerNull>(GEP->getOperand(0)))
           PointerOk = false;
+      }
 
-        // If GEP is use is not dominating loop exit then promoting
-        // GEP may expose unsafe load and store instructions unconditinally.
-        if (PointerOk)
-          for(Value::use_iterator UI = V->use_begin(), UE = V->use_end();
-              UI != UE && PointerOk; ++UI) {
-            Instruction *Use = dyn_cast<Instruction>(*UI);
-            if (!Use)
-              continue;
-            for (SmallVector<Instruction *, 4>::iterator 
-                   ExitI = LoopExits.begin(), ExitE = LoopExits.end();
-                 ExitI != ExitE; ++ExitI) {
-              Instruction *Ex = *ExitI;
-              if (!DT->dominates(Use, Ex)){
-                PointerOk = false;
-                break;
-              }
-            }
-
-            if (!PointerOk)
+      // If value V use is not dominating loop exit then promoting
+      // it may expose unsafe load and store instructions unconditinally.
+      if (PointerOk)
+        for(Value::use_iterator UI = V->use_begin(), UE = V->use_end();
+            UI != UE && PointerOk; ++UI) {
+          Instruction *Use = dyn_cast<Instruction>(*UI);
+          if (!Use || !CurLoop->contains(Use->getParent()))
+            continue;
+          for (SmallVector<Instruction *, 4>::iterator 
+                 ExitI = LoopExits.begin(), ExitE = LoopExits.end();
+               ExitI != ExitE; ++ExitI) {
+            Instruction *Ex = *ExitI;
+            if (!DT->dominates(Use, Ex)){
+              PointerOk = false;
               break;
+            }
           }
-      }
-
+          
+          if (!PointerOk)
+            break;
+        }
+      
+      
       if (PointerOk) {
         const Type *Ty = cast<PointerType>(V->getType())->getElementType();
         AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart);