[llvm] [VPlan] Invert condition if needed when creating inner regions. (PR #132292)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 26 13:29:52 PDT 2025


================
@@ -420,6 +420,17 @@ static void createLoopRegion(VPlan &Plan, VPBlockBase *HeaderVPB) {
   auto *PreheaderVPBB = HeaderVPB->getPredecessors()[0];
   auto *LatchVPBB = HeaderVPB->getPredecessors()[1];
 
+  // We are canonicalizing the successors of the latch when introducing the
+  // region. We will exit the region of the latch condition is true; invert the
+  // original condition if the original CFG branches to the header on true.
+  if (!LatchVPBB->getSingleSuccessor() &&
----------------
fhahn wrote:

At the moment, it may have 1 successor (the header, when vectorizing inner loops, where exit edges are not yet connected; that should be coming soon thought) or 2 (for inner loops when vectorizing outer loops)

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


More information about the llvm-commits mailing list