Skip to content

[VPlan] Skip disconnected exit blocks in hasEarlyExit. #151718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4229,7 +4229,10 @@ class VPlan {
/// block with multiple predecessors (one for the exit via the latch and one
/// via the other early exit).
bool hasEarlyExit() const {
return ExitBlocks.size() > 1 ||
return count_if(ExitBlocks,
[](VPIRBasicBlock *EB) {
return EB->getNumPredecessors() != 0;
}) > 1 ||
(ExitBlocks.size() == 1 && ExitBlocks[0]->getNumPredecessors() > 1);
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LoopVectorize/vect.stats.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
; vectorized) and the third one is not.

; CHECK: 4 loop-vectorize - Number of loops analyzed for vectorization
; CHECK: 2 loop-vectorize - Number of early exit loops vectorized
; CHECK: 1 loop-vectorize - Number of early exit loops vectorized
; CHECK: 3 loop-vectorize - Number of loops vectorized

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
Expand Down