[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 06:02:51 PST 2024
================
@@ -327,6 +327,37 @@ 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));
+ Value *PhiVal = State.get(getOperand(1));
+ 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"));
+
+ State.set(this, V);
+ State.addMetadata(V, dyn_cast_or_null<Instruction>(getUnderlyingValue()));
----------------
Mel-Chen wrote:
Is it possible that `getUnderlyingValue()` returns non-null value?
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list