[llvm] Expanding the Histogram Intrinsic (PR #127399)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 06:46:11 PDT 2025


================
@@ -1300,6 +1326,45 @@ void VPHistogramRecipe::print(raw_ostream &O, const Twine &Indent,
   }
 }
 
+bool VPHistogramRecipe::isLegalUpdateInstruction(Instruction *I) {
+  // We only support add and sub instructions and the following list of
+  // intrinsics: uadd.sat, umax, umin.
+  if (isa<BinaryOperator>(I))
+    return I->getOpcode() == Instruction::Add ||
+           I->getOpcode() == Instruction::Sub;
+  if (auto *II = dyn_cast<IntrinsicInst>(I)) {
+    switch (II->getIntrinsicID()) {
+    case Intrinsic::uadd_sat:
+    case Intrinsic::umax:
+    case Intrinsic::umin:
+      return true;
+    default:
+      return false;
+    }
+  }
+  return false;
+}
+
+unsigned VPHistogramRecipe::getHistogramOpcode(Instruction *I) {
----------------
huntergr-arm wrote:

Maybe better named as `getHistogramIntrinsicID()`?

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


More information about the llvm-commits mailing list