[llvm] [VPlan] Account for early-exit dispatch blocks when updating LI. (PR #185618)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:26:02 PDT 2026


================
@@ -119,3 +119,197 @@ loop.latch:
 exit:
   ret i32 1
 }
+
+; Tests that when an early-exit inner loop has multiple exits and all exits
+; leave the outer loop.
+define i32 @multi_early_exit_all_leave_outer_loop(i1 %c) {
+; CHECK-LABEL: Loop info for function 'multi_early_exit_all_leave_outer_loop':
+; CHECK: Loop at depth 1 containing: %outer.header<header>,%outer.latch<latch><exiting>,%vector.ph,%vector.body<exiting>,%vector.body.interim,%middle.block
+; CHECK:    {{.*}}Loop at depth 2 containing: %vector.body<header><exiting>,%vector.body.interim<latch><exiting>
+entry:
+  br label %outer.header
+
+outer.header:
+  br label %inner.header
+
+inner.header:
+  %iv = phi i64 [ 0, %outer.header ], [ %iv.next, %inner.latch ]
+  br i1 %c, label %early.exit.1, label %inner.body
+
+inner.body:
+  %trunc = trunc i64 %iv to i16
+  %cmp = icmp ult i16 %trunc, 0
----------------
david-arm wrote:

This is known at compile time to always return false, so the test may end up being unstable if this gets optimised in future. Perhaps change to something like

`%cmp = icmp ult i16 %trunc, 16`


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


More information about the llvm-commits mailing list