[llvm] [AArch64] Improve index selection for histograms (PR #111150)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 09:15:21 PDT 2024


================
@@ -12353,6 +12355,37 @@ SDValue DAGCombiner::visitMLOAD(SDNode *N) {
   return SDValue();
 }
 
+SDValue DAGCombiner::visitMHISTOGRAM(SDNode *N) {
+  MaskedHistogramSDNode *HG = cast<MaskedHistogramSDNode>(N);
+  SDValue Chain = HG->getChain();
+  SDValue Inc = HG->getInc();
+  SDValue Mask = HG->getMask();
+  SDValue BasePtr = HG->getBasePtr();
+  SDValue Index = HG->getIndex();
+  SDLoc DL(HG);
+
+  EVT MemVT = HG->getMemoryVT();
+  MachineMemOperand *MMO = HG->getMemOperand();
+  ISD::MemIndexType IndexType = HG->getIndexType();
+
+  if (ISD::isConstantSplatVectorAllZeros(Mask.getNode())) {
+    return Chain;
+  }
+  SDValue Ops[] = {Chain,          Inc,           Mask, BasePtr, Index,
+                   HG->getScale(), HG->getIntID()};
+  if (refineUniformBase(BasePtr, Index, HG->isIndexScaled(), DAG, DL)) {
+    return DAG.getMaskedHistogram(DAG.getVTList(MVT::Other), MemVT, DL, Ops,
+                                  MMO, IndexType);
+  }
+  EVT DataVT = Index.getValueType();
+  DataVT.changeVectorElementType(Inc.getValueType());
----------------
MacDue wrote:

Maybe note that this is making the equivalent histogram data vector type (as `inc` is a scalar).

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


More information about the llvm-commits mailing list