1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[VPlan] Add VPBasicBlock::phis() helper (NFC).

This patch introduces a helper to obtain an iterator range for the
PHI-like recipes in a block.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D100101
This commit is contained in:
Florian Hahn 2021-05-02 18:56:42 +01:00
parent afad6987f7
commit b7eb3dfd3b
2 changed files with 13 additions and 5 deletions

View File

@ -249,10 +249,7 @@ void VPBlockBase::deleteCFG(VPBlockBase *Entry) {
VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() {
iterator It = begin();
while (It != end() && (isa<VPWidenPHIRecipe>(&*It) ||
isa<VPWidenIntOrFpInductionRecipe>(&*It) ||
isa<VPPredInstPHIRecipe>(&*It) ||
isa<VPWidenCanonicalIVRecipe>(&*It)))
while (It != end() && It->isPhi())
It++;
return It;
}

View File

@ -685,6 +685,12 @@ public:
/// Returns true if the recipe may have side-effects.
bool mayHaveSideEffects() const;
/// Returns true for PHI-like recipes.
bool isPhi() const {
return getVPDefID() == VPWidenIntOrFpInductionSC || getVPDefID() == VPWidenPHISC ||
getVPDefID() == VPPredInstPHISC || getVPDefID() == VPWidenCanonicalIVSC;
}
};
inline bool VPUser::classof(const VPDef *Def) {
@ -1430,7 +1436,7 @@ public:
/// VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph. It
/// holds a sequence of zero or more VPRecipe's each representing a sequence of
/// output IR instructions.
/// output IR instructions. All PHI-like recipes must come before any non-PHI recipes.
class VPBasicBlock : public VPBlockBase {
public:
using RecipeListTy = iplist<VPRecipeBase>;
@ -1508,6 +1514,11 @@ public:
/// Return the position of the first non-phi node recipe in the block.
iterator getFirstNonPhi();
/// Returns an iterator range over the PHI-like recipes in the block.
iterator_range<iterator> phis() {
return make_range(begin(), getFirstNonPhi());
}
void dropAllReferences(VPValue *NewValue) override;
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)