llvm.org GIT mirror llvm / 734d7c2
make a couple of changes to the standard pass pipeline: 1. Only run the early (in the module pass pipe) instcombine/simplifycfg if the "unit at a time" passes they are cleaning up after runs. 2. Move the "clean up after the unroller" pass to the very end of the function-level pass pipeline. Loop unroll uses instsimplify now, so it doesn't create a ton of trash. Moving instcombine later allows it to clean up after opportunities are exposed by GVN, DSE, etc. 3. Introduce some phase ordering tests for things that are specifically intended to be simplified by the full optimizer as a whole. This resolves PR2338, and is progress towards PR6627, which will be generating code that looks similar to test2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130241 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
3 changed file(s) with 80 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
7171 Pass *InliningPass) {
7272 createStandardAliasAnalysisPasses(PM);
7373
74 // If all optimizations are disabled, just run the always-inline pass.
7475 if (OptimizationLevel == 0) {
7576 if (InliningPass)
7677 PM->add(InliningPass);
8283
8384 PM->add(createIPSCCPPass()); // IP SCCP
8485 PM->add(createDeadArgEliminationPass()); // Dead argument elimination
85 }
86 PM->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE
87 PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
86
87 PM->add(createInstructionCombiningPass());// Clean up after IPCP & DAE
88 PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
89 }
8890
8991 // Start of CallGraph SCC passes.
9092 if (UnitAtATime && HaveExceptions)
119121 PM->add(createLoopDeletionPass()); // Delete dead loops
120122 if (UnrollLoops)
121123 PM->add(createLoopUnrollPass()); // Unroll small loops
122 PM->add(createInstructionCombiningPass()); // Clean up after the unroller
123124 if (OptimizationLevel > 1)
124125 PM->add(createGVNPass()); // Remove redundancies
125126 PM->add(createMemCpyOptPass()); // Remove memcpy / form memset
133134 PM->add(createDeadStoreEliminationPass()); // Delete dead stores
134135 PM->add(createAggressiveDCEPass()); // Delete dead instructions
135136 PM->add(createCFGSimplificationPass()); // Merge & remove BBs
137 PM->add(createInstructionCombiningPass()); // Clean up after everything.
136138
137139 if (UnitAtATime) {
138140 PM->add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
0 ; RUN: opt -O3 -S %s | FileCheck %s
1
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
3 target triple = "x86_64-apple-macosx10.6.7"
4
5 declare i8* @malloc(i64)
6 declare void @free(i8*)
7
8
9 ; PR2338
10 define void @test1() nounwind ssp {
11 %retval = alloca i32, align 4
12 %i = alloca i8*, align 8
13 %call = call i8* @malloc(i64 1)
14 store i8* %call, i8** %i, align 8
15 %tmp = load i8** %i, align 8
16 store i8 1, i8* %tmp
17 %tmp1 = load i8** %i, align 8
18 call void @free(i8* %tmp1)
19 ret void
20
21 ; CHECK: @test1
22 ; CHECK-NEXT: ret void
23 }
24
25
26 ; PR6627 - This whole nasty sequence should be flattened down to a single
27 ; 32-bit comparison.
28 define void @test2(i8* %arrayidx) nounwind ssp {
29 entry:
30 %xx = bitcast i8* %arrayidx to i32*
31 %x1 = load i32* %xx, align 4
32 %tmp = trunc i32 %x1 to i8
33 %conv = zext i8 %tmp to i32
34 %cmp = icmp eq i32 %conv, 127
35 br i1 %cmp, label %land.lhs.true, label %if.end
36
37 land.lhs.true: ; preds = %entry
38 %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
39 %tmp5 = load i8* %arrayidx4, align 1
40 %conv6 = zext i8 %tmp5 to i32
41 %cmp7 = icmp eq i32 %conv6, 69
42 br i1 %cmp7, label %land.lhs.true9, label %if.end
43
44 land.lhs.true9: ; preds = %land.lhs.true
45 %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
46 %tmp13 = load i8* %arrayidx12, align 1
47 %conv14 = zext i8 %tmp13 to i32
48 %cmp15 = icmp eq i32 %conv14, 76
49 br i1 %cmp15, label %land.lhs.true17, label %if.end
50
51 land.lhs.true17: ; preds = %land.lhs.true9
52 %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
53 %tmp21 = load i8* %arrayidx20, align 1
54 %conv22 = zext i8 %tmp21 to i32
55 %cmp23 = icmp eq i32 %conv22, 70
56 br i1 %cmp23, label %if.then, label %if.end
57
58 if.then: ; preds = %land.lhs.true17
59 %call25 = call i32 (...)* @doo()
60 br label %if.end
61
62 if.end: ; preds = %if.then, %land.lhs.true17, %land.lhs.true9, %land.lhs.true, %entry
63 ret void
64
65 ; CHECK: @test2
66 ; CHECK: %x1 = load i32* %xx, align 4
67 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
68 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
69 }
70
71 declare i32 @doo(...)
72
0 load_lib llvm.exp
11
2 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
2 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]]