[llvm-commits] [llvm] r98033 - in /llvm/trunk: lib/Analysis/LoopInfo.cpp test/Transforms/LCSSA/unreachable-use.ll
Dan Gohman
gohman at apple.com
Mon Mar 8 17:53:33 PST 2010
Author: djg
Date: Mon Mar 8 19:53:33 2010
New Revision: 98033
URL: http://llvm.org/viewvc/llvm-project?rev=98033&view=rev
Log:
Make isLCSSA ignore uses in blocks not reachable from the entry block,
as LCSSA no longer transforms such uses.
Added:
llvm/trunk/test/Transforms/LCSSA/unreachable-use.ll
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=98033&r1=98032&r2=98033&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Mon Mar 8 19:53:33 2010
@@ -264,6 +264,13 @@
/// isLCSSAForm - Return true if the Loop is in LCSSA form
bool Loop::isLCSSAForm() const {
+ // Collect all the reachable blocks in the function, for fast lookups.
+ SmallPtrSet<BasicBlock *, 32> ReachableBBs;
+ BasicBlock *EntryBB = getHeader()->getParent()->begin();
+ for (df_iterator<BasicBlock *> NI = df_begin(EntryBB),
+ NE = df_end(EntryBB); NI != NE; ++NI)
+ ReachableBBs.insert(*NI);
+
// Sort the blocks vector so that we can use binary search to do quick
// lookups.
SmallPtrSet<BasicBlock *, 16> LoopBBs(block_begin(), block_end());
@@ -277,9 +284,13 @@
if (PHINode *P = dyn_cast<PHINode>(*UI))
UserBB = P->getIncomingBlock(UI);
- // Check the current block, as a fast-path. Most values are used in
- // the same block they are defined in.
- if (UserBB != BB && !LoopBBs.count(UserBB))
+ // Check the current block, as a fast-path, before checking whether
+ // the use is anywhere in the loop. Most values are used in the same
+ // block they are defined in. Also, blocks not reachable from the
+ // entry are special; uses in them don't need to go through PHIs.
+ if (UserBB != BB &&
+ !LoopBBs.count(UserBB) &&
+ ReachableBBs.count(UserBB))
return false;
}
}
Added: llvm/trunk/test/Transforms/LCSSA/unreachable-use.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LCSSA/unreachable-use.ll?rev=98033&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LCSSA/unreachable-use.ll (added)
+++ llvm/trunk/test/Transforms/LCSSA/unreachable-use.ll Mon Mar 8 19:53:33 2010
@@ -0,0 +1,27 @@
+; RUN: opt < %s -lcssa -S -verify-loop-info | grep {\[%\]tmp33 = load i1\\*\\* \[%\]tmp}
+; PR6546
+
+; LCSSA doesn't need to transform uses in blocks not reachable
+; from the entry block.
+
+define fastcc void @dfs() nounwind {
+bb:
+ br label %bb44
+
+bb44:
+ br i1 undef, label %bb7, label %bb45
+
+bb7:
+ %tmp = bitcast i1** undef to i1**
+ br label %bb15
+
+bb15:
+ br label %bb44
+
+bb32:
+ %tmp33 = load i1** %tmp, align 8
+ br label %bb45
+
+bb45:
+ unreachable
+}
More information about the llvm-commits
mailing list