llvm.org GIT mirror llvm / 9c64b96
[(new) Pass Manager] instantiate SimplifyCFG with the same options as the old PM The old PM sets the options of what used to be known as "latesimplifycfg" on the instantiation after the vectorizers have run, so that's what we'redoing here. FWIW, there's a later SimplifyCFGPass instantiation in both PMs where we do not set the "late" options. I'm not sure if that's intentional or not. Differential Revision: https://reviews.llvm.org/D39407 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316869 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 10 months ago
3 changed file(s) with 40 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
3030 SimplifyCFGOptions Options;
3131
3232 public:
33 /// The default constructor sets the pass options to create optimal IR,
34 /// rather than canonical IR. That is, by default we do transformations that
35 /// are likely to improve performance but make analysis more difficult.
36 /// FIXME: This is inverted from what most instantiations of the pass should
37 /// be.
33 /// The default constructor sets the pass options to create canonical IR,
34 /// rather than optimal IR. That is, by default we bypass transformations that
35 /// are likely to improve performance but make analysis for other passes more
36 /// difficult.
3837 SimplifyCFGPass()
3938 : SimplifyCFGPass(SimplifyCFGOptions()
40 .forwardSwitchCondToPhi(true)
41 .convertSwitchToLookupTable(true)
42 .needCanonicalLoops(false)) {}
39 .forwardSwitchCondToPhi(false)
40 .convertSwitchToLookupTable(false)
41 .needCanonicalLoops(true)) {}
42
4343
4444 /// Construct a pass with optional optimizations.
4545 SimplifyCFGPass(const SimplifyCFGOptions &PassOptions);
750750 // Optimize parallel scalar instruction chains into SIMD instructions.
751751 OptimizePM.addPass(SLPVectorizerPass());
752752
753 // Cleanup after all of the vectorizers.
754 OptimizePM.addPass(SimplifyCFGPass());
753 // Cleanup after all of the vectorizers. Simplification passes like CVP and
754 // GVN, loop transforms, and others have already run, so it's now better to
755 // convert to more optimized IR using more aggressive simplify CFG options.
756 OptimizePM.addPass(SimplifyCFGPass(SimplifyCFGOptions().
757 forwardSwitchCondToPhi(true).
758 convertSwitchToLookupTable(true).
759 needCanonicalLoops(false)));
755760 OptimizePM.addPass(InstCombinePass());
756761
757762 // Unroll small loops to hide loop backedge latency and saturate any parallel
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=OLDPM
2 ; RUN: opt -passes='default' -S < %s | FileCheck %s --check-prefix=NEWPM
1 ; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=OLDPM
2 ; RUN: opt -passes='default' -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=NEWPM
33
44 ; Don't simplify unconditional branches from empty blocks in simplifyCFG
55 ; until late in the pipeline because it can destroy canonical loop structure.
66
7 ; FIXME: The new pass manager is not limiting simplifycfg at any point in the pipeline,
8 ; so it performs a transformation before loop optimizations that is avoided in the old PM.
9
107 define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
11 ; OLDPM-LABEL: @PR33605(
12 ; OLDPM-NEXT: for.body:
13 ; OLDPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
14 ; OLDPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
15 ; OLDPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
16 ; OLDPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
17 ; OLDPM-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
18 ; OLDPM: if.then:
19 ; OLDPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
20 ; OLDPM-NEXT: tail call void @foo()
21 ; OLDPM-NEXT: br label [[IF_END]]
22 ; OLDPM: if.end:
23 ; OLDPM-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
24 ; OLDPM-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4
25 ; OLDPM-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
26 ; OLDPM-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
27 ; OLDPM: if.then.1:
28 ; OLDPM-NEXT: store i32 [[OR]], i32* [[C]], align 4
29 ; OLDPM-NEXT: tail call void @foo()
30 ; OLDPM-NEXT: br label [[IF_END_1]]
31 ; OLDPM: if.end.1:
32 ; OLDPM-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
33 ; OLDPM-NEXT: ret i1 [[CHANGED_1_OFF0_1]]
34 ;
35 ; NEWPM-LABEL: @PR33605(
36 ; NEWPM-NEXT: entry:
37 ; NEWPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
38 ; NEWPM-NEXT: br label [[FOR_COND_OUTER:%.*]]
39 ; NEWPM: for.cond.outer:
40 ; NEWPM-NEXT: [[I_0_PH:%.*]] = phi i32 [ [[DEC:%.*]], [[IF_THEN:%.*]] ], [ 2, [[ENTRY:%.*]] ]
41 ; NEWPM-NEXT: [[CHANGED_0_OFF0_PH:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY]] ]
42 ; NEWPM-NEXT: br label [[FOR_COND:%.*]]
43 ; NEWPM: for.cond:
44 ; NEWPM-NEXT: [[I_0:%.*]] = phi i32 [ [[DEC]], [[FOR_BODY:%.*]] ], [ [[I_0_PH]], [[FOR_COND_OUTER]] ]
45 ; NEWPM-NEXT: [[DEC]] = add nsw i32 [[I_0]], -1
46 ; NEWPM-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I_0]], 0
47 ; NEWPM-NEXT: br i1 [[TOBOOL]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
48 ; NEWPM: for.cond.cleanup:
49 ; NEWPM-NEXT: ret i1 [[CHANGED_0_OFF0_PH]]
50 ; NEWPM: for.body:
51 ; NEWPM-NEXT: [[IDXPROM:%.*]] = sext i32 [[DEC]] to i64
52 ; NEWPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[IDXPROM]]
53 ; NEWPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
54 ; NEWPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
55 ; NEWPM-NEXT: br i1 [[CMP]], label [[FOR_COND]], label [[IF_THEN]]
56 ; NEWPM: if.then:
57 ; NEWPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
58 ; NEWPM-NEXT: tail call void @foo()
59 ; NEWPM-NEXT: br label [[FOR_COND_OUTER]]
8 ; ALL-LABEL: @PR33605(
9 ; ALL-NEXT: for.body:
10 ; ALL-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
11 ; ALL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
12 ; ALL-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
13 ; ALL-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
14 ; ALL-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
15 ; ALL: if.then:
16 ; ALL-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
17 ; ALL-NEXT: tail call void @foo()
18 ; ALL-NEXT: br label [[IF_END]]
19 ; ALL: if.end:
20 ; ALL-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
21 ; ALL-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4
22 ; ALL-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
23 ; ALL-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
24 ; ALL: if.then.1:
25 ; ALL-NEXT: store i32 [[OR]], i32* [[C]], align 4
26 ; ALL-NEXT: tail call void @foo()
27 ; ALL-NEXT: br label [[IF_END_1]]
28 ; ALL: if.end.1:
29 ; ALL-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
30 ; ALL-NEXT: ret i1 [[CHANGED_1_OFF0_1]]
6031 ;
6132 entry:
6233 br label %for.cond