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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 12:03:15 PST 2023


================
@@ -9128,8 +9008,17 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
               : new VPInstruction(Instruction::Select, {Cond, Red, PhiR});
       Result->insertBefore(&*Builder.getInsertPoint());
       Red->replaceUsesWithIf(
-          Result->getVPSingleValue(),
-          [](VPUser &U, unsigned) { return isa<VPLiveOut>(&U); });
+          Result->getVPSingleValue(), [VectorLoopRegion](VPUser &U, unsigned) {
+            auto *UR = cast<VPRecipeBase>(&U);
+            if (UR->getParent()->getParent() != VectorLoopRegion) {
+              assert(cast<VPInstruction>(UR)->getOpcode() ==
+                         VPInstruction::ComputeReductionResult &&
+                     "user outside of the vector region must be "
+                     "ComputeReductionResult");
+              return true;
+            }
+            return false;
+          });
----------------
fhahn wrote:

Simplified, thanks!

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


More information about the llvm-commits mailing list