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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 14:54:17 PDT 2026


================
@@ -90,6 +78,26 @@ class VPRecipeBuilder {
   VPRecipeBase *tryToCreateWidenNonPhiRecipe(VPSingleDefRecipe *R,
                                              VFRange &Range);
 
+  /// Check if the load or store instruction \p VPI should widened for \p
+  /// Range.Start and potentially masked. Such instructions are handled by a
+  /// recipe that takes an additional VPInstruction for the mask.
+  VPRecipeBase *tryToWidenMemory(VPInstruction *VPI, VFRange &Range);
+
+  /// If \p VPI represents a histogram operation (as determined by
+  /// LoopVectorizationLegality) make that safe for vectorization, by emitting a
+  /// llvm.experimental.vector.histogram.add intrinsic in place of the Load +
+  /// Add|Sub + Store operations that perform the histogram in the original
+  /// scalar loop.
+  VPHistogramRecipe *widenIfHistogram(VPInstruction *VPI);
+
+  /// The stores with invariant address inside the loop will be deleted, and in
+  /// the exit block, a uniform store recipe will be created for the final
+  /// invariant store of the reduction. Returns `true` if replacement took
+  /// place. The order of stores must be preserved, hence \p
+  /// FinalRedStoresBuidler.
+  bool replaceWithFinalIfReductionStore(VPBuilder &FinalRedStoresBuilder,
+                                        VPInstruction *VPI);
----------------
fhahn wrote:

nit: I think most helpers in the builders take the VPInstruction to act on as first argument, so may be good to swap
```suggestion
  bool replaceWithFinalIfReductionStore(VPInstruction *VPI, VPBuilder &FinalRedStoresBuilder
                                        );
```

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


More information about the llvm-commits mailing list