[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 08:18:37 PDT 2024


================
@@ -308,6 +308,53 @@ InstructionCost VPRecipeBase::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");
+
+  for (unsigned Part = 0; Part < State.UF; ++Part) {
----------------
SamTebbs33 wrote:

I believe that's because the one-use restriction stops us from making partial reduction for such cases anyway. The unrolled test should cover this.

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


More information about the llvm-commits mailing list