llvm.org GIT mirror llvm / 02bf305
Approved by Chris: $ svn merge -c 113057 https://llvm.org/svn/llvm-project/llvm/trunk --- Merging r113057 into '.': A test/Transforms/LoopSimplify/preserve-scev.ll U lib/Transforms/Utils/LoopSimplify.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_28@113851 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
2 changed file(s) with 60 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
4545 #include "llvm/LLVMContext.h"
4646 #include "llvm/Type.h"
4747 #include "llvm/Analysis/AliasAnalysis.h"
48 #include "llvm/Analysis/ScalarEvolution.h"
4849 #include "llvm/Analysis/Dominators.h"
4950 #include "llvm/Analysis/LoopPass.h"
5051 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
7071 AliasAnalysis *AA;
7172 LoopInfo *LI;
7273 DominatorTree *DT;
74 ScalarEvolution *SE;
7375 Loop *L;
7476 virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
7577
8284 AU.addPreserved();
8385
8486 AU.addPreserved();
85 AU.addPreserved("scalar-evolution");
87 AU.addPreserved();
8688 AU.addPreservedID(BreakCriticalEdgesID); // No critical edges added.
8789 AU.addPreserved();
8890 AU.addPreservedID(LCSSAID);
120122 LI = &getAnalysis();
121123 AA = getAnalysisIfAvailable();
122124 DT = &getAnalysis();
125 SE = getAnalysisIfAvailable();
123126
124127 Changed |= ProcessLoop(L, LPM);
125128
531534
532535 DEBUG(dbgs() << "LoopSimplify: Splitting out a new outer loop\n");
533536
537 // If ScalarEvolution is around and knows anything about values in
538 // this loop, tell it to forget them, because we're about to
539 // substantially change it.
540 if (SE)
541 SE->forgetLoop(L);
542
534543 BasicBlock *Header = L->getHeader();
535544 BasicBlock *NewBB = SplitBlockPredecessors(Header, &OuterLoopPreds[0],
536545 OuterLoopPreds.size(),
0 ; RUN: opt -S < %s -indvars | opt -analyze -iv-users | grep {%cmp = icmp slt i32} | grep {= \{%\\.ph,+,1\}<%for.cond>}
1 ; PR8079
2
3 ; LoopSimplify should invalidate indvars when splitting out the
4 ; inner loop.
5
6 @maxStat = external global i32
7
8 define i32 @test() nounwind {
9 entry:
10 br label %for.cond
11
12 for.cond: ; preds = %if.then5, %if.end, %entry
13 %cuts.1 = phi i32 [ 0, %entry ], [ %inc, %if.then5 ], [ %cuts.1, %if.end ]
14 %0 = phi i32 [ 0, %entry ], [ %add, %if.end ], [ %add, %if.then5 ]
15 %add = add i32 %0, 1
16 %cmp = icmp slt i32 %0, 1
17 %tmp1 = load i32* @maxStat, align 4
18 br i1 %cmp, label %for.body, label %for.cond14.preheader
19
20 for.cond14.preheader: ; preds = %for.cond
21 %cmp1726 = icmp sgt i32 %tmp1, 0
22 br i1 %cmp1726, label %for.body18, label %return
23
24 for.body: ; preds = %for.cond
25 %cmp2 = icmp sgt i32 %tmp1, 100
26 br i1 %cmp2, label %return, label %if.end
27
28 if.end: ; preds = %for.body
29 %cmp4 = icmp sgt i32 %tmp1, -1
30 br i1 %cmp4, label %if.then5, label %for.cond
31
32 if.then5: ; preds = %if.end
33 call void @foo() nounwind
34 %inc = add i32 %cuts.1, 1
35 br label %for.cond
36
37 for.body18: ; preds = %for.body18, %for.cond14.preheader
38 %i13.027 = phi i32 [ %1, %for.body18 ], [ 0, %for.cond14.preheader ]
39 call void @foo() nounwind
40 %1 = add nsw i32 %i13.027, 1
41 %tmp16 = load i32* @maxStat, align 4
42 %cmp17 = icmp slt i32 %1, %tmp16
43 br i1 %cmp17, label %for.body18, label %return
44
45 return: ; preds = %for.body18, %for.body, %for.cond14.preheader
46 ret i32 0
47 }
48
49 declare void @foo() nounwind