Skip to content

Commit a77f585

Browse files
fhahnkrishna2803
authored andcommitted
[VPlan] Skip disconnected exit blocks in hasEarlyExit. (llvm#151718)
Currently hasEarlyExit returns true, if there are multiple exit blocks. ExitBlocks contains the wrapped original IR exit blocks. Without checking the predecessors we incorrectly return true for loops with multiple countable exits, that have been vectorized by requiring a scalar epilogue. In that case, the exit blocks will get disconnected. Fix this by filtering out disconnected exit blocks. Currently this should only impact the 'early-exit vectorized' statistic. PR: llvm#151718
1 parent 6310a76 commit a77f585

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4228,7 +4228,10 @@ class VPlan {
42284228
/// block with multiple predecessors (one for the exit via the latch and one
42294229
/// via the other early exit).
42304230
bool hasEarlyExit() const {
4231-
return ExitBlocks.size() > 1 ||
4231+
return count_if(ExitBlocks,
4232+
[](VPIRBasicBlock *EB) {
4233+
return EB->getNumPredecessors() != 0;
4234+
}) > 1 ||
42324235
(ExitBlocks.size() == 1 && ExitBlocks[0]->getNumPredecessors() > 1);
42334236
}
42344237

llvm/test/Transforms/LoopVectorize/vect.stats.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
; vectorized) and the third one is not.
66

77
; CHECK: 4 loop-vectorize - Number of loops analyzed for vectorization
8-
; CHECK: 2 loop-vectorize - Number of early exit loops vectorized
8+
; CHECK: 1 loop-vectorize - Number of early exit loops vectorized
99
; CHECK: 3 loop-vectorize - Number of loops vectorized
1010

1111
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"

0 commit comments

Comments
 (0)