[llvm] LV: Expand llvm.histogram intrinsic to support umax, umin, and uadd.sat operations (PR #127399)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 08:24:28 PDT 2026


================
@@ -2186,14 +2198,28 @@ class VPHistogramRecipe : public VPRecipeBase, public VPIRMetadata {
   InstructionCost computeCost(ElementCount VF,
                               VPCostContext &Ctx) const override;
 
-  unsigned getOpcode() const { return Opcode; }
+  HistogramUpdateKind getUpdateKind() const { return UpdateKind; }
+
+  /// Return the histogram intrinsic ID for this recipe's update kind.
+  Intrinsic::ID getHistogramIntrinsicID() const;
+
+  /// Return true if the increment should be negated before passing to the
+  /// histogram intrinsic (only for Sub).
+  bool shouldNegateIncrement() const {
+    return UpdateKind == HistogramUpdateKind::Sub;
+  }
 
   /// Return the mask operand if one was provided, or a null pointer if all
   /// lanes should be executed unconditionally.
   VPValue *getMask() const {
     return getNumOperands() == 3 ? getOperand(2) : nullptr;
   }
 
+  /// Return the HistogramUpdateKind for the given update instruction, or
+  /// std::nullopt if the instruction is not a supported histogram update.
+  static std::optional<HistogramUpdateKind>
+  getUpdateKindForInstruction(Instruction *I);
----------------
RonDahan101 wrote:

Done

https://github.com/llvm/llvm-project/pull/127399


More information about the llvm-commits mailing list