llvm.org GIT mirror llvm / cbac7f1
Make isLCSSA ignore uses in blocks not reachable from the entry block, as LCSSA no longer transforms such uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98033 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
2 changed file(s) with 41 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
263263
264264 /// isLCSSAForm - Return true if the Loop is in LCSSA form
265265 bool Loop::isLCSSAForm() const {
266 // Collect all the reachable blocks in the function, for fast lookups.
267 SmallPtrSet ReachableBBs;
268 BasicBlock *EntryBB = getHeader()->getParent()->begin();
269 for (df_iterator NI = df_begin(EntryBB),
270 NE = df_end(EntryBB); NI != NE; ++NI)
271 ReachableBBs.insert(*NI);
272
266273 // Sort the blocks vector so that we can use binary search to do quick
267274 // lookups.
268275 SmallPtrSet LoopBBs(block_begin(), block_end());
276283 if (PHINode *P = dyn_cast(*UI))
277284 UserBB = P->getIncomingBlock(UI);
278285
279 // Check the current block, as a fast-path. Most values are used in
280 // the same block they are defined in.
281 if (UserBB != BB && !LoopBBs.count(UserBB))
286 // Check the current block, as a fast-path, before checking whether
287 // the use is anywhere in the loop. Most values are used in the same
288 // block they are defined in. Also, blocks not reachable from the
289 // entry are special; uses in them don't need to go through PHIs.
290 if (UserBB != BB &&
291 !LoopBBs.count(UserBB) &&
292 ReachableBBs.count(UserBB))
282293 return false;
283294 }
284295 }
0 ; RUN: opt < %s -lcssa -S -verify-loop-info | grep {\[%\]tmp33 = load i1\\*\\* \[%\]tmp}
1 ; PR6546
2
3 ; LCSSA doesn't need to transform uses in blocks not reachable
4 ; from the entry block.
5
6 define fastcc void @dfs() nounwind {
7 bb:
8 br label %bb44
9
10 bb44:
11 br i1 undef, label %bb7, label %bb45
12
13 bb7:
14 %tmp = bitcast i1** undef to i1**
15 br label %bb15
16
17 bb15:
18 br label %bb44
19
20 bb32:
21 %tmp33 = load i1** %tmp, align 8
22 br label %bb45
23
24 bb45:
25 unreachable
26 }