Skip to content

Commit 04f9a8a

Browse files
committed
[ConstraintElim] Move just before loop simplification pipeline.
Adjust the pipeline slightly to move ConstraintElim just before the loop simplification pipeline. This increases the number of cases where SCEV should can preserved in the future. This also enables slightly more opportunities, by benefiting from earlier CFG simplifications, which allow more conditions to be added. Reviewed By: nikic, antoniofrighetto Differential Revision: https://reviews.llvm.org/D158843
1 parent caa2a4a commit 04f9a8a

9 files changed

+17
-22
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,6 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
557557
FPM.addPass(InstCombinePass());
558558
FPM.addPass(AggressiveInstCombinePass());
559559

560-
if (EnableConstraintElimination)
561-
FPM.addPass(ConstraintEliminationPass());
562-
563560
if (!Level.isOptimizingForSize())
564561
FPM.addPass(LibCallsShrinkWrapPass());
565562

@@ -580,6 +577,9 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
580577
// minimal multiplication trees.
581578
FPM.addPass(ReassociatePass());
582579

580+
if (EnableConstraintElimination)
581+
FPM.addPass(ConstraintEliminationPass());
582+
583583
// Add the primary loop simplification pipeline.
584584
// FIXME: Currently this is split into two loop pass pipelines because we run
585585
// some function passes in between them. These can and should be removed

llvm/test/Other/new-pm-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@
154154
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
155155
; CHECK-O-NEXT: Running pass: InstCombinePass
156156
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
157-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
158157
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
159158
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
160159
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
161160
; CHECK-EP-PEEPHOLE-NEXT: Running pass: NoOpFunctionPass
162161
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
163162
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
164163
; CHECK-O-NEXT: Running pass: ReassociatePass
164+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
165165
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
166166
; CHECK-O-NEXT: Running analysis: LoopAnalysis
167167
; CHECK-O-NEXT: Running pass: LCSSAPass

llvm/test/Other/new-pm-thinlto-postlink-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@
9292
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
9393
; CHECK-O-NEXT: Running pass: InstCombinePass
9494
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
95-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
9695
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
9796
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
9897
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
9998
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
10099
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
101100
; CHECK-O-NEXT: Running pass: ReassociatePass
101+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
102102
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
103103
; CHECK-O-NEXT: Running analysis: LoopAnalysis
104104
; CHECK-O-NEXT: Running pass: LCSSAPass

llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
8282
; CHECK-O-NEXT: Running pass: InstCombinePass
8383
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
84-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
8584
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
8685
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
8786
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
8887
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
8988
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
9089
; CHECK-O-NEXT: Running pass: ReassociatePass
90+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
9191
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
9292
; CHECK-O-NEXT: Running pass: LCSSAPass
9393
; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis

llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@
8888
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
8989
; CHECK-O-NEXT: Running pass: InstCombinePass
9090
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
91-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
9291
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
9392
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
9493
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
9594
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
9695
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
9796
; CHECK-O-NEXT: Running pass: ReassociatePass
97+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
9898
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
9999
; CHECK-O-NEXT: Running pass: LCSSAPass
100100
; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis

llvm/test/Other/new-pm-thinlto-prelink-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@
124124
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
125125
; CHECK-O-NEXT: Running pass: InstCombinePass
126126
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
127-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
128127
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
129128
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
130129
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
131130
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
132131
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
133132
; CHECK-O-NEXT: Running pass: ReassociatePass
133+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
134134
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
135135
; CHECK-O-NEXT: Running analysis: LoopAnalysis
136136
; CHECK-O-NEXT: Running pass: LCSSAPass

llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
; CHECK-O-NEXT: Running analysis: LoopAnalysis on foo
126126
; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo
127127
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
128-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
129128
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
130129
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
131130
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
@@ -134,6 +133,7 @@
134133
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
135134
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
136135
; CHECK-O-NEXT: Running pass: ReassociatePass
136+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
137137
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
138138
; CHECK-O-NEXT: Running pass: LCSSAPass
139139
; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis

llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@
9393
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
9494
; CHECK-O-NEXT: Running pass: InstCombinePass
9595
; CHECK-O23SZ-NEXT: Running pass: AggressiveInstCombinePass
96-
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
9796
; CHECK-O1-NEXT: Running pass: LibCallsShrinkWrapPass
9897
; CHECK-O2-NEXT: Running pass: LibCallsShrinkWrapPass
9998
; CHECK-O3-NEXT: Running pass: LibCallsShrinkWrapPass
10099
; CHECK-O23SZ-NEXT: Running pass: TailCallElimPass
101100
; CHECK-O-NEXT: Running pass: SimplifyCFGPass
102101
; CHECK-O-NEXT: Running pass: ReassociatePass
102+
; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass
103103
; CHECK-O-NEXT: Running pass: LoopSimplifyPass
104104
; CHECK-O-NEXT: Running pass: LCSSAPass
105105
; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis

llvm/test/Transforms/PhaseOrdering/AArch64/constraint-elimination-placement.ll

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,25 @@ define i1 @test_order_1(ptr %this, ptr noalias %other, i1 %tobool9.not, i32 %cal
1010
; CHECK-NEXT: entry:
1111
; CHECK-NEXT: br i1 [[TOBOOL9_NOT]], label [[EXIT:%.*]], label [[FOR_COND_PREHEADER:%.*]]
1212
; CHECK: for.cond.preheader:
13-
; CHECK-NEXT: [[CMP40_NOT4:%.*]] = icmp slt i32 [[CALL]], 1
14-
; CHECK-NEXT: br i1 [[CMP40_NOT4]], label [[FOR_COND41_PREHEADER_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
13+
; CHECK-NEXT: [[CMP40_NOT3:%.*]] = icmp slt i32 [[CALL]], 1
14+
; CHECK-NEXT: br i1 [[CMP40_NOT3]], label [[FOR_COND41_PREHEADER_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1515
; CHECK: for.cond41.preheader.preheader:
1616
; CHECK-NEXT: [[TMP0:%.*]] = sext i32 [[CALL]] to i64
1717
; CHECK-NEXT: br label [[FOR_COND41_PREHEADER:%.*]]
1818
; CHECK: for.cond:
1919
; CHECK-NEXT: [[INDVARS_IV_NEXT:%.*]] = add nsw i64 [[INDVARS_IV:%.*]], 1
2020
; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[INDVARS_IV_NEXT]], 4294967295
2121
; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[TMP1]], 1
22-
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_COND41_PREHEADER]]
22+
; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP]], label [[FOR_COND41_PREHEADER]]
2323
; CHECK: for.cond41.preheader:
2424
; CHECK-NEXT: [[INDVARS_IV]] = phi i64 [ [[TMP0]], [[FOR_COND41_PREHEADER_PREHEADER]] ], [ [[INDVARS_IV_NEXT]], [[FOR_COND:%.*]] ]
25-
; CHECK-NEXT: [[CALL432:%.*]] = load volatile i32, ptr [[OTHER]], align 4
26-
; CHECK-NEXT: [[CMP443:%.*]] = icmp sgt i32 [[CALL432]], 0
27-
; CHECK-NEXT: br i1 [[CMP443]], label [[FOR_BODY45_LR_PH:%.*]], label [[FOR_COND]]
25+
; CHECK-NEXT: [[CALL431:%.*]] = load volatile i32, ptr [[OTHER]], align 4
26+
; CHECK-NEXT: [[CMP442:%.*]] = icmp sgt i32 [[CALL431]], 0
27+
; CHECK-NEXT: br i1 [[CMP442]], label [[FOR_BODY45_LR_PH:%.*]], label [[FOR_COND]]
2828
; CHECK: for.body45.lr.ph:
2929
; CHECK-NEXT: [[ARRAYIDX_I_I:%.*]] = getelementptr ptr, ptr [[OTHER]], i64 [[INDVARS_IV]]
3030
; CHECK-NEXT: br label [[FOR_BODY45:%.*]]
31-
; CHECK: for.cond.cleanup.loopexit:
32-
; CHECK-NEXT: [[CMP40_NOT:%.*]] = icmp slt i64 [[INDVARS_IV]], 0
33-
; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
3431
; CHECK: for.cond.cleanup:
35-
; CHECK-NEXT: [[CMP40_NOT_LCSSA:%.*]] = phi i1 [ false, [[FOR_COND_PREHEADER]] ], [ [[CMP40_NOT]], [[FOR_COND_CLEANUP_LOOPEXIT]] ]
3632
; CHECK-NEXT: store i32 0, ptr [[THIS]], align 4
3733
; CHECK-NEXT: br label [[EXIT]]
3834
; CHECK: for.body45:
@@ -41,8 +37,7 @@ define i1 @test_order_1(ptr %this, ptr noalias %other, i1 %tobool9.not, i32 %cal
4137
; CHECK-NEXT: [[CMP44:%.*]] = icmp sgt i32 [[CALL43]], 0
4238
; CHECK-NEXT: br i1 [[CMP44]], label [[FOR_BODY45]], label [[FOR_COND]]
4339
; CHECK: exit:
44-
; CHECK-NEXT: [[TMP2:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP40_NOT_LCSSA]], [[FOR_COND_CLEANUP]] ]
45-
; CHECK-NEXT: ret i1 [[TMP2]]
40+
; CHECK-NEXT: ret i1 false
4641
;
4742
entry:
4843
%retval1 = alloca i1, i32 0, align 1

0 commit comments

Comments
 (0)