[llvm] [LV] Vectorize histogram operations (PR #99851)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 03:54:15 PDT 2024


================
@@ -1021,6 +1022,94 @@ void VPWidenCallRecipe::print(raw_ostream &O, const Twine &Indent,
     O << ")";
   }
 }
+#endif
+
+void VPHistogramRecipe::execute(VPTransformState &State) {
+  State.setDebugLocFrom(getDebugLoc());
+  IRBuilderBase &Builder = State.Builder;
+
+  Value *Address = State.get(getOperand(0));
+  Value *IncAmt = State.get(getOperand(1), /*IsScalar=*/true);
+  VectorType *VTy = cast<VectorType>(Address->getType());
+
+  // The histogram intrinsic requires a mask even if the recipe doesn't;
+  // if the mask operand was omitted then all lanes should be executed and
+  // we just need to synthesize an all-true mask.
+  Value *Mask = nullptr;
+  if (VPValue *VPMask = getMask())
+    Mask = State.get(VPMask);
+  else
+    Mask = Builder.CreateVectorSplat(VTy->getElementCount(),
+                                     ConstantInt::getTrue(Builder.getInt1Ty()));
----------------
huntergr-arm wrote:

done

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


More information about the llvm-commits mailing list