Skip to content

Commit a8d7451

Browse files
committed
[PassManager] Run Induction Variable Simplification pass *after* Recognize loop idioms pass, not before
Currently, `-indvars` runs first, and then immediately after `-loop-idiom` does. I'm not really sure if `-loop-idiom` requires `-indvars` to run beforehand, but i'm *very* sure that `-indvars` requires `-loop-idiom` to run afterwards, as it can be seen in the phase-ordering test. LoopIdiom runs on two types of loops: countable ones, and uncountable ones. For uncountable ones, IndVars obviously didn't make any change to them, since they are uncountable, so for them the order should be irrelevant. For countable ones, well, they should have been countable before IndVars for IndVars to make any change to them, and since SCEV is used on them, it shouldn't matter if IndVars have already canonicalized them. So i don't really see why we'd want the current ordering. Should this cause issues, it will give us a reproducer test case that shows flaws in this logic, and we then could adjust accordingly. While this is quite likely beneficial in-the-wild already, it's a required part for the full motivational pattern behind `left-shift-until-bittest` loop idiom (D91038). Reviewed By: dmgreen Differential Revision: https://reviews.llvm.org/D91800
1 parent 1933c9d commit a8d7451

15 files changed

+27
-93
lines changed

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
521521

522522
if (EnableLoopFlatten)
523523
FPM.addPass(LoopFlattenPass());
524-
LPM2.addPass(IndVarSimplifyPass());
525524
LPM2.addPass(LoopIdiomRecognizePass());
525+
LPM2.addPass(IndVarSimplifyPass());
526526

527527
for (auto &C : LateLoopOptimizationsEPCallbacks)
528528
C(LPM2, Level);
@@ -682,8 +682,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
682682
// TODO: Investigate promotion cap for O1.
683683
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
684684
LPM1.addPass(SimpleLoopUnswitchPass());
685-
LPM2.addPass(IndVarSimplifyPass());
686685
LPM2.addPass(LoopIdiomRecognizePass());
686+
LPM2.addPass(IndVarSimplifyPass());
687687

688688
for (auto &C : LateLoopOptimizationsEPCallbacks)
689689
C(LPM2, Level);
@@ -712,7 +712,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
712712
DebugLogging));
713713
FPM.addPass(SimplifyCFGPass());
714714
FPM.addPass(InstCombinePass());
715-
// The loop passes in LPM2 (IndVarSimplifyPass, LoopIdiomRecognizePass,
715+
// The loop passes in LPM2 (LoopIdiomRecognizePass, IndVarSimplifyPass,
716716
// LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.
717717
// *All* loop passes must preserve it, in order to be able to use it.
718718
FPM.addPass(createFunctionToLoopPassAdaptor(

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
445445
MPM.add(createLoopFlattenPass()); // Flatten loops
446446
MPM.add(createLoopSimplifyCFGPass());
447447
}
448-
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
449448
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
449+
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
450450
addExtensionsToPM(EP_LateLoopOptimizations, MPM);
451451
MPM.add(createLoopDeletionPass()); // Delete dead loops
452452

llvm/test/CodeGen/AMDGPU/opt-pipeline.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
; GCN-O1-NEXT: Loop-Closed SSA Form Pass
164164
; GCN-O1-NEXT: Scalar Evolution Analysis
165165
; GCN-O1-NEXT: Loop Pass Manager
166-
; GCN-O1-NEXT: Induction Variable Simplification
167166
; GCN-O1-NEXT: Recognize loop idioms
167+
; GCN-O1-NEXT: Induction Variable Simplification
168168
; GCN-O1-NEXT: Delete dead loops
169169
; GCN-O1-NEXT: Unroll loops
170170
; GCN-O1-NEXT: SROA

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
; CHECK-O-NEXT: Running pass: LCSSAPass
164164
; CHECK-O-NEXT: Finished llvm::Function pass manager run.
165165
; CHECK-O-NEXT: Starting Loop pass manager run.
166-
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
167166
; CHECK-O-NEXT: Running pass: LoopIdiomRecognizePass
167+
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
168168
; CHECK-EP-LOOP-LATE-NEXT: Running pass: NoOpLoopPass
169169
; CHECK-O-NEXT: Running pass: LoopDeletionPass
170170
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@
147147
; CHECK-O-NEXT: Running pass: LCSSAPass
148148
; CHECK-O-NEXT: Finished llvm::Function pass manager run
149149
; CHECK-O-NEXT: Starting Loop pass manager run.
150-
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
151150
; CHECK-O-NEXT: Running pass: LoopIdiomRecognizePass
151+
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
152152
; CHECK-O-NEXT: Running pass: LoopDeletionPass
153153
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
154154
; CHECK-O-NEXT: Finished Loop pass manager run.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120
; CHECK-O-NEXT: Running pass: LCSSAPass
121121
; CHECK-O-NEXT: Finished {{.*}}Function pass manager run
122122
; CHECK-O-NEXT: Starting Loop pass manager run.
123-
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
124123
; CHECK-O-NEXT: Running pass: LoopIdiomRecognizePass
124+
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
125125
; CHECK-O-NEXT: Running pass: LoopDeletionPass
126126
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
127127
; CHECK-O-NEXT: Finished Loop pass manager run.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@
128128
; CHECK-O-NEXT: Running pass: LCSSAPass
129129
; CHECK-O-NEXT: Finished {{.*}}Function pass manager run
130130
; CHECK-O-NEXT: Starting Loop pass manager run.
131-
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
132131
; CHECK-O-NEXT: Running pass: LoopIdiomRecognizePass
132+
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
133133
; CHECK-O-NEXT: Running pass: LoopDeletionPass
134134
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
135135
; CHECK-O-NEXT: Finished Loop pass manager run.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@
168168
; CHECK-O-NEXT: Running pass: LCSSAPass
169169
; CHECK-O-NEXT: Finished {{.*}}Function pass manager run
170170
; CHECK-O-NEXT: Starting Loop pass manager run.
171-
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
172171
; CHECK-O-NEXT: Running pass: LoopIdiomRecognizePass
172+
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
173173
; CHECK-O-NEXT: Running pass: LoopDeletionPass
174174
; CHECK-O-NEXT: Running pass: LoopFullUnrollPass
175175
; CHECK-O-NEXT: Finished Loop pass manager run.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@
124124
; CHECK-O-NEXT: Running pass: LCSSAPass
125125
; CHECK-O-NEXT: Finished {{.*}}Function pass manager run
126126
; CHECK-O-NEXT: Starting Loop pass manager run.
127-
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
128127
; CHECK-O-NEXT: Running pass: LoopIdiomRecognizePass
128+
; CHECK-O-NEXT: Running pass: IndVarSimplifyPass
129129
; CHECK-O-NEXT: Running pass: LoopDeletionPass
130130
; CHECK-O-NEXT: Finished Loop pass manager run.
131131
; CHECK-O-NEXT: Running pass: SROA on foo

llvm/test/Other/opt-O2-pipeline.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
; CHECK-NEXT: Loop-Closed SSA Form Pass
132132
; CHECK-NEXT: Scalar Evolution Analysis
133133
; CHECK-NEXT: Loop Pass Manager
134-
; CHECK-NEXT: Induction Variable Simplification
135134
; CHECK-NEXT: Recognize loop idioms
135+
; CHECK-NEXT: Induction Variable Simplification
136136
; CHECK-NEXT: Delete dead loops
137137
; CHECK-NEXT: Unroll loops
138138
; CHECK-NEXT: SROA

llvm/test/Other/opt-O3-pipeline-enable-matrix.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
; CHECK-NEXT: Loop-Closed SSA Form Pass
137137
; CHECK-NEXT: Scalar Evolution Analysis
138138
; CHECK-NEXT: Loop Pass Manager
139-
; CHECK-NEXT: Induction Variable Simplification
140139
; CHECK-NEXT: Recognize loop idioms
140+
; CHECK-NEXT: Induction Variable Simplification
141141
; CHECK-NEXT: Delete dead loops
142142
; CHECK-NEXT: Unroll loops
143143
; CHECK-NEXT: SROA

llvm/test/Other/opt-O3-pipeline.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
; CHECK-NEXT: Loop-Closed SSA Form Pass
137137
; CHECK-NEXT: Scalar Evolution Analysis
138138
; CHECK-NEXT: Loop Pass Manager
139-
; CHECK-NEXT: Induction Variable Simplification
140139
; CHECK-NEXT: Recognize loop idioms
140+
; CHECK-NEXT: Induction Variable Simplification
141141
; CHECK-NEXT: Delete dead loops
142142
; CHECK-NEXT: Unroll loops
143143
; CHECK-NEXT: SROA

llvm/test/Other/opt-Os-pipeline.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
; CHECK-NEXT: Loop-Closed SSA Form Pass
118118
; CHECK-NEXT: Scalar Evolution Analysis
119119
; CHECK-NEXT: Loop Pass Manager
120-
; CHECK-NEXT: Induction Variable Simplification
121120
; CHECK-NEXT: Recognize loop idioms
121+
; CHECK-NEXT: Induction Variable Simplification
122122
; CHECK-NEXT: Delete dead loops
123123
; CHECK-NEXT: Unroll loops
124124
; CHECK-NEXT: SROA

llvm/test/Transforms/PhaseOrdering/ARM/arm_fill_q7.ll

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,15 @@ target triple = "thumbv6m-none-none-eabi"
1212
define dso_local void @arm_fill_q7(i8 signext %value, i8* %pDst, i32 %blockSize) #0 {
1313
; OLDPM-LABEL: @arm_fill_q7(
1414
; OLDPM-NEXT: entry:
15-
; OLDPM-NEXT: [[SHR:%.*]] = lshr i32 [[BLOCKSIZE:%.*]], 2
16-
; OLDPM-NEXT: [[CMP_NOT20:%.*]] = icmp eq i32 [[SHR]], 0
15+
; OLDPM-NEXT: [[CMP_NOT20:%.*]] = icmp ult i32 [[BLOCKSIZE:%.*]], 4
1716
; OLDPM-NEXT: br i1 [[CMP_NOT20]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]]
1817
; OLDPM: while.body.preheader:
1918
; OLDPM-NEXT: [[TMP0:%.*]] = and i32 [[BLOCKSIZE]], -4
2019
; OLDPM-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST:%.*]], i8 [[VALUE:%.*]], i32 [[TMP0]], i1 false)
21-
; OLDPM-NEXT: br label [[WHILE_BODY:%.*]]
22-
; OLDPM: while.body:
23-
; OLDPM-NEXT: [[BLKCNT_022:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[SHR]], [[WHILE_BODY_PREHEADER]] ]
24-
; OLDPM-NEXT: [[PDST_ADDR_021:%.*]] = phi i8* [ [[ADD_PTR_I:%.*]], [[WHILE_BODY]] ], [ [[PDST]], [[WHILE_BODY_PREHEADER]] ]
25-
; OLDPM-NEXT: [[ADD_PTR_I]] = getelementptr inbounds i8, i8* [[PDST_ADDR_021]], i32 4
26-
; OLDPM-NEXT: [[DEC]] = add nsw i32 [[BLKCNT_022]], -1
27-
; OLDPM-NEXT: [[CMP_NOT:%.*]] = icmp eq i32 [[DEC]], 0
28-
; OLDPM-NEXT: br i1 [[CMP_NOT]], label [[WHILE_END]], label [[WHILE_BODY]], [[LOOP3:!llvm.loop !.*]]
20+
; OLDPM-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PDST]], i32 [[TMP0]]
21+
; OLDPM-NEXT: br label [[WHILE_END]]
2922
; OLDPM: while.end:
30-
; OLDPM-NEXT: [[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] ], [ [[ADD_PTR_I]], [[WHILE_BODY]] ]
23+
; OLDPM-NEXT: [[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] ], [ [[SCEVGEP]], [[WHILE_BODY_PREHEADER]] ]
3124
; OLDPM-NEXT: [[REM:%.*]] = and i32 [[BLOCKSIZE]], 3
3225
; OLDPM-NEXT: [[CMP14_NOT17:%.*]] = icmp eq i32 [[REM]], 0
3326
; OLDPM-NEXT: br i1 [[CMP14_NOT17]], label [[WHILE_END18:%.*]], label [[WHILE_BODY16_PREHEADER:%.*]]
@@ -39,22 +32,15 @@ define dso_local void @arm_fill_q7(i8 signext %value, i8* %pDst, i32 %blockSize)
3932
;
4033
; NEWPM-LABEL: @arm_fill_q7(
4134
; NEWPM-NEXT: entry:
42-
; NEWPM-NEXT: [[SHR:%.*]] = lshr i32 [[BLOCKSIZE:%.*]], 2
43-
; NEWPM-NEXT: [[CMP_NOT17:%.*]] = icmp eq i32 [[SHR]], 0
35+
; NEWPM-NEXT: [[CMP_NOT17:%.*]] = icmp ult i32 [[BLOCKSIZE:%.*]], 4
4436
; NEWPM-NEXT: br i1 [[CMP_NOT17]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]]
4537
; NEWPM: while.body.preheader:
4638
; NEWPM-NEXT: [[TMP0:%.*]] = and i32 [[BLOCKSIZE]], -4
4739
; NEWPM-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST:%.*]], i8 [[VALUE:%.*]], i32 [[TMP0]], i1 false)
48-
; NEWPM-NEXT: br label [[WHILE_BODY:%.*]]
49-
; NEWPM: while.body:
50-
; NEWPM-NEXT: [[BLKCNT_019:%.*]] = phi i32 [ [[DEC:%.*]], [[WHILE_BODY]] ], [ [[SHR]], [[WHILE_BODY_PREHEADER]] ]
51-
; NEWPM-NEXT: [[PDST_ADDR_018:%.*]] = phi i8* [ [[ADD_PTR_I:%.*]], [[WHILE_BODY]] ], [ [[PDST]], [[WHILE_BODY_PREHEADER]] ]
52-
; NEWPM-NEXT: [[ADD_PTR_I]] = getelementptr inbounds i8, i8* [[PDST_ADDR_018]], i32 4
53-
; NEWPM-NEXT: [[DEC]] = add nsw i32 [[BLKCNT_019]], -1
54-
; NEWPM-NEXT: [[CMP_NOT:%.*]] = icmp eq i32 [[DEC]], 0
55-
; NEWPM-NEXT: br i1 [[CMP_NOT]], label [[WHILE_END]], label [[WHILE_BODY]], [[LOOP3:!llvm.loop !.*]]
40+
; NEWPM-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PDST]], i32 [[TMP0]]
41+
; NEWPM-NEXT: br label [[WHILE_END]]
5642
; NEWPM: while.end:
57-
; NEWPM-NEXT: [[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] ], [ [[ADD_PTR_I]], [[WHILE_BODY]] ]
43+
; NEWPM-NEXT: [[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] ], [ [[SCEVGEP]], [[WHILE_BODY_PREHEADER]] ]
5844
; NEWPM-NEXT: [[REM:%.*]] = and i32 [[BLOCKSIZE]], 3
5945
; NEWPM-NEXT: [[CMP14_NOT20:%.*]] = icmp eq i32 [[REM]], 0
6046
; NEWPM-NEXT: br i1 [[CMP14_NOT20]], label [[WHILE_END18:%.*]], label [[WHILE_BODY16_PREHEADER:%.*]]

llvm/test/Transforms/PhaseOrdering/X86/loop-idiom-vs-indvars.ll

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,10 @@ define i32 @cttz(i32 %n, i32* %p1) {
1313
; ALL-NEXT: entry:
1414
; ALL-NEXT: [[TMP0:%.*]] = shl i32 [[N:%.*]], 1
1515
; ALL-NEXT: [[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 false), [[RNG0:!range !.*]]
16-
; ALL-NEXT: [[TMP2:%.*]] = sub nuw nsw i32 33, [[TMP1]]
17-
; ALL-NEXT: [[TMP3:%.*]] = sub nuw nsw i32 33, [[TMP1]]
18-
; ALL-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ugt i32 [[TMP1]], 25
19-
; ALL-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[WHILE_COND_PREHEADER:%.*]], label [[VECTOR_PH:%.*]]
20-
; ALL: vector.ph:
21-
; ALL-NEXT: [[N_VEC:%.*]] = and i32 [[TMP3]], -8
22-
; ALL-NEXT: [[IND_END:%.*]] = sub nsw i32 [[TMP2]], [[N_VEC]]
23-
; ALL-NEXT: [[TMP4:%.*]] = add nsw i32 [[N_VEC]], -8
24-
; ALL-NEXT: [[TMP5:%.*]] = lshr exact i32 [[TMP4]], 3
25-
; ALL-NEXT: [[TMP6:%.*]] = add nuw nsw i32 [[TMP5]], 1
26-
; ALL-NEXT: [[XTRAITER:%.*]] = and i32 [[TMP6]], 7
27-
; ALL-NEXT: [[TMP7:%.*]] = icmp ult i32 [[TMP4]], 56
28-
; ALL-NEXT: br i1 [[TMP7]], label [[MIDDLE_BLOCK_UNR_LCSSA:%.*]], label [[VECTOR_PH_NEW:%.*]]
29-
; ALL: vector.ph.new:
30-
; ALL-NEXT: [[UNROLL_ITER:%.*]] = and i32 [[TMP6]], 1073741816
31-
; ALL-NEXT: br label [[VECTOR_BODY:%.*]]
32-
; ALL: vector.body:
33-
; ALL-NEXT: [[VEC_PHI:%.*]] = phi <8 x i32> [ <i32 42, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>, [[VECTOR_PH_NEW]] ], [ [[TMP8:%.*]], [[VECTOR_BODY]] ]
34-
; ALL-NEXT: [[NITER:%.*]] = phi i32 [ [[UNROLL_ITER]], [[VECTOR_PH_NEW]] ], [ [[NITER_NSUB_7:%.*]], [[VECTOR_BODY]] ]
35-
; ALL-NEXT: [[TMP8]] = add <8 x i32> [[VEC_PHI]], <i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
36-
; ALL-NEXT: [[NITER_NSUB_7]] = add i32 [[NITER]], -8
37-
; ALL-NEXT: [[NITER_NCMP_7:%.*]] = icmp eq i32 [[NITER_NSUB_7]], 0
38-
; ALL-NEXT: br i1 [[NITER_NCMP_7]], label [[MIDDLE_BLOCK_UNR_LCSSA]], label [[VECTOR_BODY]], [[LOOP1:!llvm.loop !.*]]
39-
; ALL: middle.block.unr-lcssa:
40-
; ALL-NEXT: [[DOTLCSSA_PH:%.*]] = phi <8 x i32> [ undef, [[VECTOR_PH]] ], [ [[TMP8]], [[VECTOR_BODY]] ]
41-
; ALL-NEXT: [[VEC_PHI_UNR:%.*]] = phi <8 x i32> [ <i32 42, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>, [[VECTOR_PH]] ], [ [[TMP8]], [[VECTOR_BODY]] ]
42-
; ALL-NEXT: [[LCMP_MOD_NOT:%.*]] = icmp eq i32 [[XTRAITER]], 0
43-
; ALL-NEXT: br i1 [[LCMP_MOD_NOT]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY_EPIL:%.*]]
44-
; ALL: vector.body.epil:
45-
; ALL-NEXT: [[VEC_PHI_EPIL:%.*]] = phi <8 x i32> [ [[TMP9:%.*]], [[VECTOR_BODY_EPIL]] ], [ [[VEC_PHI_UNR]], [[MIDDLE_BLOCK_UNR_LCSSA]] ]
46-
; ALL-NEXT: [[EPIL_ITER:%.*]] = phi i32 [ [[EPIL_ITER_SUB:%.*]], [[VECTOR_BODY_EPIL]] ], [ [[XTRAITER]], [[MIDDLE_BLOCK_UNR_LCSSA]] ]
47-
; ALL-NEXT: [[TMP9]] = add <8 x i32> [[VEC_PHI_EPIL]], <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
48-
; ALL-NEXT: [[EPIL_ITER_SUB]] = add i32 [[EPIL_ITER]], -1
49-
; ALL-NEXT: [[EPIL_ITER_CMP_NOT:%.*]] = icmp eq i32 [[EPIL_ITER_SUB]], 0
50-
; ALL-NEXT: br i1 [[EPIL_ITER_CMP_NOT]], label [[MIDDLE_BLOCK]], label [[VECTOR_BODY_EPIL]], [[LOOP3:!llvm.loop !.*]]
51-
; ALL: middle.block:
52-
; ALL-NEXT: [[DOTLCSSA:%.*]] = phi <8 x i32> [ [[DOTLCSSA_PH]], [[MIDDLE_BLOCK_UNR_LCSSA]] ], [ [[TMP9]], [[VECTOR_BODY_EPIL]] ]
53-
; ALL-NEXT: [[TMP10:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[DOTLCSSA]])
54-
; ALL-NEXT: [[CMP_N:%.*]] = icmp eq i32 [[TMP3]], [[N_VEC]]
55-
; ALL-NEXT: br i1 [[CMP_N]], label [[WHILE_END:%.*]], label [[WHILE_COND_PREHEADER]]
56-
; ALL: while.cond.preheader:
57-
; ALL-NEXT: [[TCPHI_PH:%.*]] = phi i32 [ [[TMP2]], [[ENTRY:%.*]] ], [ [[IND_END]], [[MIDDLE_BLOCK]] ]
58-
; ALL-NEXT: [[WHATEVER_PH:%.*]] = phi i32 [ 42, [[ENTRY]] ], [ [[TMP10]], [[MIDDLE_BLOCK]] ]
59-
; ALL-NEXT: br label [[WHILE_COND:%.*]]
60-
; ALL: while.cond:
61-
; ALL-NEXT: [[TCPHI:%.*]] = phi i32 [ [[TCDEC:%.*]], [[WHILE_COND]] ], [ [[TCPHI_PH]], [[WHILE_COND_PREHEADER]] ]
62-
; ALL-NEXT: [[WHATEVER:%.*]] = phi i32 [ [[WHATEVER_NEXT:%.*]], [[WHILE_COND]] ], [ [[WHATEVER_PH]], [[WHILE_COND_PREHEADER]] ]
63-
; ALL-NEXT: [[TCDEC]] = add nsw i32 [[TCPHI]], -1
64-
; ALL-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[TCDEC]], 0
65-
; ALL-NEXT: [[WHATEVER_NEXT]] = add nuw nsw i32 [[WHATEVER]], 1
66-
; ALL-NEXT: br i1 [[TOBOOL]], label [[WHILE_END]], label [[WHILE_COND]], [[LOOP5:!llvm.loop !.*]]
67-
; ALL: while.end:
68-
; ALL-NEXT: [[WHATEVER_NEXT_LCSSA:%.*]] = phi i32 [ [[TMP10]], [[MIDDLE_BLOCK]] ], [ [[WHATEVER_NEXT]], [[WHILE_COND]] ]
69-
; ALL-NEXT: [[TMP11:%.*]] = sub nuw nsw i32 32, [[TMP1]]
70-
; ALL-NEXT: store i32 [[WHATEVER_NEXT_LCSSA]], i32* [[P1:%.*]], align 4
71-
; ALL-NEXT: ret i32 [[TMP11]]
16+
; ALL-NEXT: [[TMP2:%.*]] = sub nuw nsw i32 32, [[TMP1]]
17+
; ALL-NEXT: [[TMP3:%.*]] = sub nuw nsw i32 75, [[TMP1]]
18+
; ALL-NEXT: store i32 [[TMP3]], i32* [[P1:%.*]], align 4
19+
; ALL-NEXT: ret i32 [[TMP2]]
7220
;
7321
entry:
7422
br label %while.cond

0 commit comments

Comments
 (0)