[VPlan] Helper to check if a recipe uses scalar values of op.

This patch adds a helper to check if a recipe only uses scalars of a
given operand. This is similar to onlyFirstLaneUsed, which was
introduced earlier.

By default, usesScalars falls back on onlyFirstLaneUsed.

Will be used by D120828.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D120827
This commit is contained in:
Florian Hahn 2022-03-11 13:41:08 +00:00
parent 7781f61efa
commit ecea477df3
No known key found for this signature in database
GPG Key ID: CF59919C6547A668
1 changed files with 22 additions and 0 deletions

View File

@ -772,6 +772,14 @@ public:
"Op must be an operand of the recipe");
return false;
}
/// Returns true if the recipe uses scalars of operand \p Op. Conservatively
/// returns if only first (scalar) lane is used, as default.
virtual bool usesScalars(const VPValue *Op) const {
assert(is_contained(operands(), Op) &&
"Op must be an operand of the recipe");
return onlyFirstLaneUsed(Op);
}
};
inline bool VPUser::classof(const VPDef *Def) {
@ -1558,6 +1566,13 @@ public:
"Op must be an operand of the recipe");
return isUniform();
}
/// Returns true if the recipe uses scalars of operand \p Op.
bool usesScalars(const VPValue *Op) const override {
assert(is_contained(operands(), Op) &&
"Op must be an operand of the recipe");
return true;
}
};
/// A recipe for generating conditional branches on the bits of a mask.
@ -1626,6 +1641,13 @@ public:
void print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const override;
#endif
/// Returns true if the recipe uses scalars of operand \p Op.
bool usesScalars(const VPValue *Op) const override {
assert(is_contained(operands(), Op) &&
"Op must be an operand of the recipe");
return true;
}
};
/// A Recipe for widening load/store operations.