[llvm] [LV] Use SCEV loop-uniformity for outer-loop branch legality (PR #199632)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 04:09:30 PDT 2026
================
@@ -91,6 +91,41 @@ exit:
ret void
}
+; The inner loop's exit condition depends on the outer loop's induction
+; variable, so its backedge branch is divergent across outer-loop iterations
+; and the outer loop must not be vectorized.
+define void @inner_loop_divergence_exit(ptr %a, i64 %N) {
+; CHECK-LABEL: LV: Checking a loop in 'inner_loop_divergence_exit'
+; CHECK: LV: Not vectorizing: Outer loop contains divergent conditional branch.
+; CHECK: LV: Not vectorizing: Unsupported outer loop.
+; CHECK: LV: Not vectorizing: Cannot prove legality.
+entry:
+ %cmp16.not = icmp eq i64 %N, 0
+ br i1 %cmp16.not, label %exit, label %outer.body
+
+outer.body: ; preds = %entry, %outer.latch
+ %i.017 = phi i64 [ %inc6, %outer.latch ], [ 0, %entry ]
----------------
fhahn wrote:
```suggestion
%outer.iv = phi i64 [ 0, %entry ], [ %inc6, %outer.latch ]
```
https://github.com/llvm/llvm-project/pull/199632
More information about the llvm-commits
mailing list