[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 04:27:03 PDT 2024
================
@@ -327,6 +327,38 @@ InstructionCost VPSingleDefRecipe::computeCost(ElementCount VF,
return UI ? Ctx.getLegacyCost(UI, VF) : 0;
}
+void VPPartialReductionRecipe::execute(VPTransformState &State) {
+ State.setDebugLocFrom(getDebugLoc());
+ auto &Builder = State.Builder;
+
+ assert(Opcode == Instruction::Add && "Unhandled partial reduction opcode");
+
+ Value *BinOpVal = State.get(getOperand(0), 0);
+ Value *PhiVal = State.get(getOperand(1), 0);
+ assert(PhiVal && BinOpVal && "Phi and Mul must be set");
+
+ Type *RetTy = PhiVal->getType();
+
+ CallInst *V = Builder.CreateIntrinsic(
+ RetTy, Intrinsic::experimental_vector_partial_reduce_add,
+ {PhiVal, BinOpVal}, nullptr, Twine("partial.reduce"));
+
+ // Use this vector value for all users of the original instruction.
+ State.set(this, V, 0);
----------------
huntergr-arm wrote:
3rd operand can be removed here for the same reason, we're not setting scalar values.
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list