[llvm] [AArch64][SVE] Add partial reduction SDNodes (PR #117185)

James Chesterman via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 02:20:58 PST 2025


================
@@ -8135,15 +8135,19 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
     return;
   }
   case Intrinsic::experimental_vector_partial_reduce_add: {
+    SDLoc dl = getCurSDLoc();
+    SDValue Acc = getValue(I.getOperand(0));
+    EVT AccVT = Acc.getValueType();
+    SDValue Input = getValue(I.getOperand(1));
 
     if (!TLI.shouldExpandPartialReductionIntrinsic(cast<IntrinsicInst>(&I))) {
-      visitTargetIntrinsic(I, Intrinsic);
+      setValue(&I, DAG.getNode(ISD::PARTIAL_REDUCE_UMLA, dl, AccVT, Acc, Input,
+                               DAG.getConstant(1, dl, Input.getValueType())));
       return;
     }
-
-    setValue(&I, DAG.getPartialReduceAdd(sdl, EVT::getEVT(I.getType()),
-                                         getValue(I.getOperand(0)),
-                                         getValue(I.getOperand(1))));
+    setValue(&I,
+             DAG.expandPartialReduceAdd(
----------------
JamesChesterman wrote:

Thank you for the recommendation. I've done it this way now, so the intrinsic is always changed to the ISD node in `SelectionDAGBuilder.cpp`. This way I've been able to remove `shouldExpandPartialReductionIntrinsic()` too. I've just put a call to `DAG.expandPartialReduceAdd` at the end of `performPartialReduceAddCombine()` in `AArch64ISelLowering.cpp`.

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


More information about the llvm-commits mailing list