Skip to content

Commit 2ec01e4

Browse files
authored
[VPlan] Move two VPBlockUtils members (NFC) (#162507)
1 parent 9e7209c commit 2ec01e4

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,32 +217,6 @@ VPBlockBase *VPBlockBase::getEnclosingBlockWithPredecessors() {
217217
return Parent->getEnclosingBlockWithPredecessors();
218218
}
219219

220-
bool VPBlockUtils::isHeader(const VPBlockBase *VPB,
221-
const VPDominatorTree &VPDT) {
222-
auto *VPBB = dyn_cast<VPBasicBlock>(VPB);
223-
if (!VPBB)
224-
return false;
225-
226-
// If VPBB is in a region R, VPBB is a loop header if R is a loop region with
227-
// VPBB as its entry, i.e., free of predecessors.
228-
if (auto *R = VPBB->getParent())
229-
return !R->isReplicator() && !VPBB->hasPredecessors();
230-
231-
// A header dominates its second predecessor (the latch), with the other
232-
// predecessor being the preheader
233-
return VPB->getPredecessors().size() == 2 &&
234-
VPDT.dominates(VPB, VPB->getPredecessors()[1]);
235-
}
236-
237-
bool VPBlockUtils::isLatch(const VPBlockBase *VPB,
238-
const VPDominatorTree &VPDT) {
239-
// A latch has a header as its second successor, with its other successor
240-
// leaving the loop. A preheader OTOH has a header as its first (and only)
241-
// successor.
242-
return VPB->getNumSuccessors() == 2 &&
243-
VPBlockUtils::isHeader(VPB->getSuccessors()[1], VPDT);
244-
}
245-
246220
VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() {
247221
iterator It = begin();
248222
while (It != end() && It->isPhi())

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "VPlanUtils.h"
1010
#include "VPlanCFG.h"
11+
#include "VPlanDominatorTree.h"
1112
#include "VPlanPatternMatch.h"
1213
#include "llvm/ADT/TypeSwitch.h"
1314
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
@@ -253,3 +254,29 @@ vputils::getRecipesForUncountableExit(VPlan &Plan,
253254

254255
return UncountableCondition;
255256
}
257+
258+
bool VPBlockUtils::isHeader(const VPBlockBase *VPB,
259+
const VPDominatorTree &VPDT) {
260+
auto *VPBB = dyn_cast<VPBasicBlock>(VPB);
261+
if (!VPBB)
262+
return false;
263+
264+
// If VPBB is in a region R, VPBB is a loop header if R is a loop region with
265+
// VPBB as its entry, i.e., free of predecessors.
266+
if (auto *R = VPBB->getParent())
267+
return !R->isReplicator() && !VPBB->hasPredecessors();
268+
269+
// A header dominates its second predecessor (the latch), with the other
270+
// predecessor being the preheader
271+
return VPB->getPredecessors().size() == 2 &&
272+
VPDT.dominates(VPB, VPB->getPredecessors()[1]);
273+
}
274+
275+
bool VPBlockUtils::isLatch(const VPBlockBase *VPB,
276+
const VPDominatorTree &VPDT) {
277+
// A latch has a header as its second successor, with its other successor
278+
// leaving the loop. A preheader OTOH has a header as its first (and only)
279+
// successor.
280+
return VPB->getNumSuccessors() == 2 &&
281+
VPBlockUtils::isHeader(VPB->getSuccessors()[1], VPDT);
282+
}

0 commit comments

Comments
 (0)