[llvm] [VPlan] Sink single-scalar replicates in licm (PR #187047)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 02:40:25 PDT 2026


================
@@ -2739,10 +2739,16 @@ static void licm(VPlan &Plan) {
       if (cannotHoistOrSinkRecipe(R))
         continue;
 
-      // TODO: Support sinking VPReplicateRecipe after ensuring replicateByVF
-      // handles sunk recipes correctly.
-      if (isa<VPReplicateRecipe>(&R))
-        continue;
+      if (auto *RepR = dyn_cast<VPReplicateRecipe>(&R)) {
+        assert(!RepR->isPredicated() &&
+               "Expected prior transformation of predicated replicates to "
+               "replicate regions");
+        // narrowToSingleScalarRecipes should have already maximally narrowed
+        // replicates to single-scalar replicates. TODO: When unrolling,
+        // replicatebyVF crashes on non-single-scalar replicates that are sunk.
----------------
Mel-Chen wrote:

```suggestion
        // replicates to single-scalar replicates. 
        // TODO: When unrolling, replicateByVF doesn't handle sunk 
        // non-single-scalar replicates correctly.
```

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


More information about the llvm-commits mailing list