A loop may be unswitched multiple times. Reconstruct dom info. at the end.
authorDevang Patel <dpatel@apple.com>
Thu, 4 Sep 2008 22:43:59 +0000 (22:43 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 4 Sep 2008 22:43:59 +0000 (22:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55806 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnswitch.cpp

index 691a67a4275141964c45fc142ce023f3d085e9e7..1c4bba295bd98e8d336bef0e8e099f5b29f17bd8 100644 (file)
@@ -190,6 +190,7 @@ bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) {
   DF = getAnalysisToUpdate<DominanceFrontier>();
   DT = getAnalysisToUpdate<DominatorTree>();
   currentLoop = L;
+  Function *F = currentLoop->getHeader()->getParent();
   bool Changed = false;
   do {
     assert(currentLoop->isLCSSAForm());
@@ -197,6 +198,13 @@ bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) {
     Changed |= processCurrentLoop();
   } while(redoLoop);
 
+  if (Changed) {
+    // FIXME: Reconstruct dom info, because it is not preserved properly.
+    if (DT)
+      DT->runOnFunction(*F);
+    if (DF)
+      DF->runOnFunction(*F);
+  }
   return Changed;
 }
 
@@ -450,11 +458,6 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
     UnswitchNontrivialCondition(LoopCond, Val, currentLoop);
   }
 
-  // FIXME: Reconstruct dom info, because it is not preserved properly.
-  if (DT)
-    DT->runOnFunction(*F);
-  if (DF)
-    DF->runOnFunction(*F);
   return true;
 }