[llvm] [NFCI][VPlan] Split initial mem-widening into a separate transformation (PR #182592)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 11 03:48:37 PDT 2026


================
@@ -7990,6 +7998,26 @@ VPHistogramRecipe *VPRecipeBuilder::tryToWidenHistogram(const HistogramInfo *HI,
   return new VPHistogramRecipe(Opcode, HGramOps, VPI->getDebugLoc());
 }
 
+bool VPRecipeBuilder::replaceWithFinalIfReductionStore(
+    VPBuilder &FinalRedStoresBuilder, VPInstruction *VPI) {
+  StoreInst *SI;
+  if ((SI = dyn_cast<StoreInst>(VPI->getUnderlyingInstr())) &&
+      Legal->isInvariantAddressOfReduction(SI->getPointerOperand())) {
+    // Only create recipe for the final invariant store of the reduction.
+    if (Legal->isInvariantStoreOfReduction(SI)) {
+      auto *Recipe = new VPReplicateRecipe(
+          SI, VPI->operandsWithoutMask(), true /* IsUniform */,
+          nullptr /*Mask*/, *VPI, *VPI, VPI->getDebugLoc());
+      FinalRedStoresBuilder.insert(Recipe);
----------------
lukel97 wrote:

Can this just return the new replicate recipe and have the caller do the insertion so we don't need to pass through the builder?

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


More information about the llvm-commits mailing list