@@ -53,14 +53,10 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) {
53
53
VPBasicBlock *VecBB = Plan->getVectorLoopRegion ()->getEntryBasicBlock ();
54
54
EXPECT_EQ (7u , VecBB->size ());
55
55
EXPECT_EQ (0u , VecBB->getNumPredecessors ());
56
- EXPECT_EQ (1u , VecBB->getNumSuccessors ());
56
+ EXPECT_EQ (0u , VecBB->getNumSuccessors ());
57
57
EXPECT_EQ (VecBB->getParent ()->getEntryBasicBlock (), VecBB);
58
58
EXPECT_EQ (&*Plan, VecBB->getPlan ());
59
59
60
- VPBlockBase *VecLatch = VecBB->getSingleSuccessor ();
61
- EXPECT_EQ (VecLatch->getParent ()->getExitingBasicBlock (), VecLatch);
62
- EXPECT_EQ (0u , VecLatch->getNumSuccessors ());
63
-
64
60
auto Iter = VecBB->begin ();
65
61
VPWidenPHIRecipe *Phi = dyn_cast<VPWidenPHIRecipe>(&*Iter++);
66
62
EXPECT_NE (nullptr , Phi);
@@ -130,33 +126,28 @@ compound=true
130
126
" EMIT store ir\<%res\>, ir\<%arr.idx\>\l" +
131
127
" EMIT ir\<%indvars.iv.next\> = add ir\<%indvars.iv\>, ir\<1\>\l" +
132
128
" EMIT ir\<%exitcond\> = icmp ir\<%indvars.iv.next\>, ir\<%N\>\l" +
133
- "Successor(s): vector.latch\l"
134
- ]
135
- N2 -> N4 [ label=""]
136
- N4 [label =
137
- "vector.latch:\l" +
138
129
"No successors\l"
139
130
]
140
131
}
141
- N4 -> N5 [ label="" ltail=cluster_N3]
142
- N5 [label =
132
+ N2 -> N4 [ label="" ltail=cluster_N3]
133
+ N4 [label =
143
134
"middle.block:\l" +
144
135
" EMIT vp\<%cmp.n\> = icmp eq ir\<%N\>, vp\<%0\>\l" +
145
136
" EMIT branch-on-cond vp\<%cmp.n\>\l" +
146
137
"Successor(s): ir-bb\<for.end\>, scalar.ph\l"
147
138
]
148
- N5 -> N6 [ label="T"]
149
- N5 -> N7 [ label="F"]
150
- N6 [label =
139
+ N4 -> N5 [ label="T"]
140
+ N4 -> N6 [ label="F"]
141
+ N5 [label =
151
142
"ir-bb\<for.end\>:\l" +
152
143
"No successors\l"
153
144
]
154
- N7 [label =
145
+ N6 [label =
155
146
"scalar.ph:\l" +
156
147
"Successor(s): ir-bb\<for.body\>\l"
157
148
]
158
- N7 -> N8 [ label=""]
159
- N8 [label =
149
+ N6 -> N7 [ label=""]
150
+ N7 [label =
160
151
"ir-bb\<for.body\>:\l" +
161
152
" IR %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\l" +
162
153
" IR %arr.idx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv\l" +
@@ -171,10 +162,6 @@ compound=true
171
162
)" ;
172
163
EXPECT_EQ (ExpectedStr, FullDump);
173
164
#endif
174
- TargetLibraryInfoImpl TLII (M.getTargetTriple ());
175
- TargetLibraryInfo TLI (TLII);
176
- VPlanTransforms::tryToConvertVPInstructionsToVPRecipes (
177
- Plan, [](PHINode *P) { return nullptr ; }, *SE, TLI);
178
165
}
179
166
180
167
TEST_F (VPlanHCFGTest, testVPInstructionToVPRecipesInner) {
@@ -203,6 +190,12 @@ TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) {
203
190
204
191
TargetLibraryInfoImpl TLII (M.getTargetTriple ());
205
192
TargetLibraryInfo TLI (TLII);
193
+ // Current VPlan construction doesn't add a terminator for top-level loop
194
+ // latches. Add it before running transform.
195
+ cast<VPBasicBlock>(Plan->getVectorLoopRegion ()->getExiting ())
196
+ ->appendRecipe (new VPInstruction (
197
+ VPInstruction::BranchOnCond,
198
+ {Plan->getOrAddLiveIn (ConstantInt::getTrue (F->getContext ()))}));
206
199
VPlanTransforms::tryToConvertVPInstructionsToVPRecipes (
207
200
Plan, [](PHINode *P) { return nullptr ; }, *SE, TLI);
208
201
@@ -214,15 +207,11 @@ TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) {
214
207
// Check that the region following the preheader consists of a block for the
215
208
// original header and a separate latch.
216
209
VPBasicBlock *VecBB = Plan->getVectorLoopRegion ()->getEntryBasicBlock ();
217
- EXPECT_EQ (7u , VecBB->size ());
210
+ EXPECT_EQ (8u , VecBB->size ());
218
211
EXPECT_EQ (0u , VecBB->getNumPredecessors ());
219
- EXPECT_EQ (1u , VecBB->getNumSuccessors ());
212
+ EXPECT_EQ (0u , VecBB->getNumSuccessors ());
220
213
EXPECT_EQ (VecBB->getParent ()->getEntryBasicBlock (), VecBB);
221
214
222
- VPBlockBase *VecLatch = VecBB->getSingleSuccessor ();
223
- EXPECT_EQ (VecLatch->getParent ()->getExitingBasicBlock (), VecLatch);
224
- EXPECT_EQ (0u , VecLatch->getNumSuccessors ());
225
-
226
215
auto Iter = VecBB->begin ();
227
216
EXPECT_NE (nullptr , dyn_cast<VPWidenPHIRecipe>(&*Iter++));
228
217
EXPECT_NE (nullptr , dyn_cast<VPWidenGEPRecipe>(&*Iter++));
@@ -231,6 +220,7 @@ TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) {
231
220
EXPECT_NE (nullptr , dyn_cast<VPWidenMemoryRecipe>(&*Iter++));
232
221
EXPECT_NE (nullptr , dyn_cast<VPWidenRecipe>(&*Iter++));
233
222
EXPECT_NE (nullptr , dyn_cast<VPWidenRecipe>(&*Iter++));
223
+ EXPECT_NE (nullptr , dyn_cast<VPInstruction>(&*Iter++));
234
224
EXPECT_EQ (VecBB->end (), Iter);
235
225
}
236
226
@@ -303,33 +293,28 @@ compound=true
303
293
" EMIT store ir\<%res\>, ir\<%arr.idx\>\l" +
304
294
" EMIT ir\<%iv.next\> = add ir\<%iv\>, ir\<1\>\l" +
305
295
" EMIT ir\<%exitcond\> = icmp ir\<%iv.next\>, ir\<%N\>\l" +
306
- "Successor(s): vector.latch\l"
307
- ]
308
- N4 -> N5 [ label=""]
309
- N5 [label =
310
- "vector.latch:\l" +
311
296
"No successors\l"
312
297
]
313
298
}
314
- N5 -> N6 [ label="" ltail=cluster_N3]
315
- N6 [label =
299
+ N4 -> N5 [ label="" ltail=cluster_N3]
300
+ N5 [label =
316
301
"middle.block:\l" +
317
302
" EMIT vp\<%cmp.n\> = icmp eq ir\<%N\>, vp\<%0\>\l" +
318
303
" EMIT branch-on-cond vp\<%cmp.n\>\l" +
319
304
"Successor(s): ir-bb\<exit.2\>, scalar.ph\l"
320
305
]
321
- N6 -> N7 [ label="T"]
322
- N6 -> N8 [ label="F"]
323
- N7 [label =
306
+ N5 -> N6 [ label="T"]
307
+ N5 -> N7 [ label="F"]
308
+ N6 [label =
324
309
"ir-bb\<exit.2\>:\l" +
325
310
"No successors\l"
326
311
]
327
- N8 [label =
312
+ N7 [label =
328
313
"scalar.ph:\l" +
329
314
"Successor(s): ir-bb\<loop.header\>\l"
330
315
]
331
- N8 -> N9 [ label=""]
332
- N9 [label =
316
+ N7 -> N8 [ label=""]
317
+ N8 [label =
333
318
"ir-bb\<loop.header\>:\l" +
334
319
" IR %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\l" +
335
320
" IR %arr.idx = getelementptr inbounds i32, ptr %A, i64 %iv\l" +
0 commit comments