[llvm] [VPlan] Connect Entry to scalar preheader during initial construction. (PR #140132)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 12:52:22 PDT 2025


================
@@ -4246,7 +4246,8 @@ class VPlan {
   /// that this relies on unneeded branches to the scalar tail loop being
   /// removed.
   bool hasScalarTail() const {
-    return getScalarPreheader()->getNumPredecessors() != 0;
+    return getScalarPreheader()->getNumPredecessors() != 0 &&
+           getScalarPreheader()->getSinglePredecessor() != getEntry();
----------------
ayalz wrote:

Perhaps clearer as:
```suggestion
    return !(getScalarPreheader()->getNumPredecessors() == 0 ||
           getScalarPreheader()->getSinglePredecessor() == getEntry());
```
I.e., scalar loop does not take care of leftover iterations if (a) it doesn't take care of anything, or (b) it only takes care of all iterations as an alternative to the vector loop?
The latter may reach scalar loop from various bypassing blocks?

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


More information about the llvm-commits mailing list