[llvm] Add an all-in-one histogram intrinsic, along with lowering for AArch64 (PR #88106)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 01:43:49 PDT 2024
================
@@ -6673,6 +6677,56 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
return LowerFunnelShift(Op, DAG);
case ISD::FLDEXP:
return LowerFLDEXP(Op, DAG);
+ case ISD::EXPERIMENTAL_HISTOGRAM: {
+ // FIXME: Move to another function.
+ // FIXME: Maybe share some code with LowerMGather/Scatter?
+ MaskedHistogramSDNode *HG = cast<MaskedHistogramSDNode>(Op);
+ SDLoc DL(HG);
+ SDValue Chain = HG->getOperand(0);
+ SDValue Inc = HG->getOperand(1);
+ SDValue Mask = HG->getOperand(2);
+ SDValue Ptr = HG->getOperand(3);
+ SDValue Index = HG->getOperand(4);
+ SDValue Scale = HG->getOperand(5);
+
+ EVT IncVT = Inc.getValueType();
+ EVT IndexVT = Index.getValueType();
+ EVT MemVT = EVT::getVectorVT(*DAG.getContext(), IncVT,
+ IndexVT.getVectorElementCount());
+ SDValue Zero = DAG.getConstant(0, DL, MVT::i64);
+ SDValue PassThru = DAG.getSplatVector(MemVT, DL, Zero);
+ SDValue IncSplat = DAG.getSplatVector(MemVT, DL, Inc);
+ SDValue Ops[] = {Chain, PassThru, Mask, Ptr, Index, Scale};
+
+ // Set the MMO to load only, rather than load|store.
+ MachineMemOperand *GMMO = HG->getMemOperand();
+ GMMO->setFlags(MachineMemOperand::MOLoad);
+ ISD::MemIndexType IndexType = HG->getIndexType();
+ SDValue Gather =
+ DAG.getMaskedGather(DAG.getVTList(MemVT, MVT::Other), MemVT, DL,
+ Ops, HG->getMemOperand(),
----------------
huntergr-arm wrote:
Ah, I think I see what you meant now; the diff wasn't quite clear after the forced push. Done.
https://github.com/llvm/llvm-project/pull/88106
More information about the llvm-commits
mailing list