[llvm-commits] [llvm] r137341 - /llvm/trunk/lib/Analysis/LoopInfo.cpp
Andrew Trick
atrick at apple.com
Thu Aug 11 13:27:32 PDT 2011
Author: atrick
Date: Thu Aug 11 15:27:32 2011
New Revision: 137341
URL: http://llvm.org/viewvc/llvm-project?rev=137341&view=rev
Log:
Fix for LoopInfo::updateUnloop. Remove subloop blocks from former
ancestor loops.
I have a unit test that depends on scev-unroll, which unfortunately
isn't checked in. But I will check it in when I can.
Modified:
llvm/trunk/lib/Analysis/LoopInfo.cpp
Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=137341&r1=137340&r2=137341&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Thu Aug 11 15:27:32 2011
@@ -411,6 +411,8 @@
void updateBlockParents();
+ void removeBlocksFromAncestors();
+
void updateSubloopParents();
protected:
@@ -467,6 +469,31 @@
}
}
+/// removeBlocksFromAncestors - Remove unloop's blocks from all ancestors below
+/// their new parents.
+void UnloopUpdater::removeBlocksFromAncestors() {
+ // Remove unloop's blocks from all ancestors below their new parents.
+ for (Loop::block_iterator BI = Unloop->block_begin(),
+ BE = Unloop->block_end(); BI != BE; ++BI) {
+ Loop *NewParent = LI->getLoopFor(*BI);
+ // If this block is an immediate subloop, remove all blocks (including
+ // nested subloops) from ancestors below the new parent loop.
+ // Otherwise, if this block is in a nested subloop, skip it.
+ if (SubloopParents.count(NewParent))
+ NewParent = SubloopParents[NewParent];
+ else if (Unloop->contains(NewParent))
+ continue;
+
+ // Remove blocks from former Ancestors except Unloop itself which will be
+ // deleted.
+ for (Loop *OldParent = Unloop->getParentLoop(); OldParent != NewParent;
+ OldParent = OldParent->getParentLoop()) {
+ assert(OldParent && "new loop is not an ancestor of the original");
+ OldParent->removeBlockFromLoop(*BI);
+ }
+ }
+}
+
/// updateSubloopParents - Update the parent loop for all subloops directly
/// nested within unloop.
void UnloopUpdater::updateSubloopParents() {
@@ -605,22 +632,8 @@
UnloopUpdater Updater(Unloop, this);
Updater.updateBlockParents();
- // Remove unloop's blocks from all ancestors below their new parents.
- for (Loop::block_iterator BI = Unloop->block_begin(),
- BE = Unloop->block_end(); BI != BE; ++BI) {
- Loop *NewParent = getLoopFor(*BI);
- // If this block is in a subloop, skip it.
- if (Unloop->contains(NewParent))
- continue;
-
- // Remove blocks from former Ancestors except Unloop itself which will be
- // deleted.
- for (Loop *OldParent = Unloop->getParentLoop(); OldParent != NewParent;
- OldParent = OldParent->getParentLoop()) {
- assert(OldParent && "new loop is not an ancestor of the original");
- OldParent->removeBlockFromLoop(*BI);
- }
- }
+ // Remove blocks from former ancestor loops.
+ Updater.removeBlocksFromAncestors();
// Add direct subloops as children in their new parent loop.
Updater.updateSubloopParents();
More information about the llvm-commits
mailing list