[llvm] ecea477 - [VPlan] Helper to check if a recipe uses scalar values of op.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 05:41:26 PST 2022
Author: Florian Hahn
Date: 2022-03-11T13:41:08Z
New Revision: ecea477df3c929d14aacca0581bc26ff3c83498c
URL: https://github.com/llvm/llvm-project/commit/ecea477df3c929d14aacca0581bc26ff3c83498c
DIFF: https://github.com/llvm/llvm-project/commit/ecea477df3c929d14aacca0581bc26ff3c83498c.diff
LOG: [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
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 8ad95110ca800..a8a8f516db472 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -772,6 +772,14 @@ class VPRecipeBase : public ilist_node_with_parent<VPRecipeBase, VPBasicBlock>,
"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 @@ class VPReplicateRecipe : public VPRecipeBase, public VPValue {
"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 @@ class VPPredInstPHIRecipe : public VPRecipeBase, public VPValue {
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.
More information about the llvm-commits
mailing list