[llvm] [VPlan] Introduce ComputeReductionResult VPInstruction opcode. (PR #70253)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 1 01:56:41 PST 2024


================
@@ -9151,9 +9011,12 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
               ? new VPInstruction(Instruction::Select, {Cond, Red, PhiR}, FMFs)
               : new VPInstruction(Instruction::Select, {Cond, Red, PhiR});
       Result->insertBefore(&*Builder.getInsertPoint());
-      Red->replaceUsesWithIf(
-          Result->getVPSingleValue(),
-          [](VPUser &U, unsigned) { return isa<VPLiveOut>(&U); });
+      Red->replaceUsesWithIf(Result->getVPSingleValue(),
----------------
ayalz wrote:

Would it be better to introduce these `Select`'s for non in-loop reductions under tail folding, along with the introduction of `ComputeReductionResult`? Rather than first introducing the latter and then searching to replace its operand by the former.

Note that these Selects originally had to be introduced inside the loop, but can now be placed in the middle block alongside ComputeReductionResult.

nit (unrelated to this patch): is the enclosing `for` statement mis-indented, along with its preceding `Builder.setInsertPoint(&*LatchVPBB->begin());` statement?

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


More information about the llvm-commits mailing list