[llvm] [LV] Vectorize histogram operations (PR #99851)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 06:21:59 PDT 2024
================
@@ -1575,6 +1577,52 @@ class VPWidenCallRecipe : public VPSingleDefRecipe {
#endif
};
+/// A recipe representing a sequence of load -> update -> store as part of
+/// a histogram operation. This means there may be aliasing between vector
+/// lanes, which is handled by the llvm.experimental.vector.histogram family
+/// of intrinsics. The only update operations currently supported are
+/// 'add' and 'sub' where the other term is loop-invariant.
+class VPHistogramRecipe : public VPRecipeBase {
+ const HistogramInfo &Info;
+ unsigned Opcode;
+
+public:
+ template <typename IterT>
+ VPHistogramRecipe(const HistogramInfo &HI, unsigned Opcode,
+ iterator_range<IterT> Operands, DebugLoc DL = {})
+ : VPRecipeBase(VPDef::VPHistogramSC, Operands, DL), Info(HI),
+ Opcode(Opcode) {}
+
+ ~VPHistogramRecipe() override = default;
+
+ VPHistogramRecipe *clone() override {
+ llvm_unreachable("cloning not supported");
+ }
+
+ VP_CLASSOF_IMPL(VPDef::VPHistogramSC);
+
+ /// Produce a vectorized histogram operation.
+ void execute(VPTransformState &State) override;
+
+ unsigned getOpcode() const { return Opcode; }
+
+ const HistogramInfo &getHistogramInfo() const { return Info; }
+
+ /// Return the mask operand if one was provided, or a null pointer if all
+ /// lanes should be executed unconditionally.
+ VPValue *getMask() const {
+ if (getNumOperands() == 3)
+ return getOperand(2);
+ return nullptr;
----------------
huntergr-arm wrote:
done.
https://github.com/llvm/llvm-project/pull/99851
More information about the llvm-commits
mailing list