Skip to content

Commit b0697dc

Browse files
authored
[LV] Only check isVectorizableEarlyExitLoop with multiple exits. (#121994)
Currently we emit early-exit related debug messages/remarks even when there is a single exit. Update to only check isVectorizableEarlyExitLoop if there isn't a single exit block. PR: #121994
1 parent c8ee116 commit b0697dc

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,14 +1814,23 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
18141814

18151815
HasUncountableEarlyExit = false;
18161816
if (isa<SCEVCouldNotCompute>(PSE.getBackedgeTakenCount())) {
1817-
HasUncountableEarlyExit = true;
1818-
if (!isVectorizableEarlyExitLoop()) {
1819-
UncountableExitingBlocks.clear();
1820-
HasUncountableEarlyExit = false;
1817+
if (TheLoop->getExitingBlock()) {
1818+
reportVectorizationFailure("Cannot vectorize uncountable loop",
1819+
"UnsupportedUncountableLoop", ORE, TheLoop);
18211820
if (DoExtraAnalysis)
18221821
Result = false;
18231822
else
18241823
return false;
1824+
} else {
1825+
HasUncountableEarlyExit = true;
1826+
if (!isVectorizableEarlyExitLoop()) {
1827+
UncountableExitingBlocks.clear();
1828+
HasUncountableEarlyExit = false;
1829+
if (DoExtraAnalysis)
1830+
Result = false;
1831+
else
1832+
return false;
1833+
}
18251834
}
18261835
}
18271836

llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
; }
1313
; }
1414
; File, line, and column should match those specified in the metadata
15-
; CHECK: remark: source.cpp:5:9: loop not vectorized: Cannot vectorize early exit loop
15+
; CHECK: remark: source.cpp:5:9: loop not vectorized: Cannot vectorize uncountable loop
1616
; CHECK: remark: source.cpp:5:9: loop not vectorized
1717

1818
; void test_disabled(int *A, int Length) {
@@ -46,12 +46,12 @@
4646

4747
; YAML: --- !Analysis
4848
; YAML-NEXT: Pass: loop-vectorize
49-
; YAML-NEXT: Name: EarlyExitNotLatchPredecessor
49+
; YAML-NEXT: Name: UnsupportedUncountableLoop
5050
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 5, Column: 9 }
5151
; YAML-NEXT: Function: _Z4testPii
5252
; YAML-NEXT: Args:
5353
; YAML-NEXT: - String: 'loop not vectorized: '
54-
; YAML-NEXT: - String: Cannot vectorize early exit loop
54+
; YAML-NEXT: - String: Cannot vectorize uncountable loop
5555
; YAML-NEXT: ...
5656
; YAML-NEXT: --- !Missed
5757
; YAML-NEXT: Pass: loop-vectorize
@@ -117,12 +117,12 @@
117117
; YAML-NEXT: ...
118118
; YAML-NEXT: --- !Analysis
119119
; YAML-NEXT: Pass: loop-vectorize
120-
; YAML-NEXT: Name: EarlyExitNotLatchPredecessor
120+
; YAML-NEXT: Name: UnsupportedUncountableLoop
121121
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 27, Column: 3 }
122122
; YAML-NEXT: Function: test_multiple_failures
123123
; YAML-NEXT: Args:
124124
; YAML-NEXT: - String: 'loop not vectorized: '
125-
; YAML-NEXT: - String: Cannot vectorize early exit loop
125+
; YAML-NEXT: - String: Cannot vectorize uncountable loop
126126
; YAML-NEXT: ...
127127
; YAML: --- !Missed
128128
; YAML-NEXT: Pass: loop-vectorize

llvm/test/Transforms/LoopVectorize/early_exit_legality.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ loop.end:
357357

358358
define i64 @uncountable_exit_infinite_loop() {
359359
; CHECK-LABEL: LV: Checking a loop in 'uncountable_exit_infinite_loop'
360-
; CHECK: LV: Not vectorizing: Cannot determine exact exit count for latch block.
360+
; CHECK: LV: Not vectorizing: Cannot vectorize uncountable loop.
361361
entry:
362362
%p1 = alloca [1024 x i8]
363363
%p2 = alloca [1024 x i8]

llvm/test/Transforms/LoopVectorize/uncountable-single-exit-loops.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
; REQUIRES: asserts
2-
; RUN: opt -p loop-vectorize -debug %s 2>&1 | FileCheck %s
2+
; RUN: opt -p loop-vectorize -debug-only=loop-vectorize -S %s 2>&1 | FileCheck %s
33

44

55
; CHECK-LABEL: LV: Checking a loop in 'latch_exit_cannot_compute_btc_due_to_step'
66
; CHECK: LV: Did not find one integer induction var.
7-
; CHECK-NEXT: LV: Not vectorizing: Early exit is not the latch predecessor.
7+
; CHECK-NEXT: LV: Not vectorizing: Cannot vectorize uncountable loop.
88
; CHECK-NEXT: LV: Interleaving disabled by the pass manager
99
; CHECK-NEXT: LV: Not vectorizing: Cannot prove legality.
1010

1111
; CHECK-LABEL: LV: Checking a loop in 'header_exit_cannot_compute_btc_due_to_step'
1212
; CHECK: LV: Found an induction variable.
1313
; CHECK-NEXT: LV: Did not find one integer induction var.
14-
; CHECK-NEXT: LV: Not vectorizing: Cannot determine exact exit count for latch block.
14+
; CHECK-NEXT: LV: Not vectorizing: Cannot vectorize uncountable loop.
1515
; CHECK-NEXT: LV: Interleaving disabled by the pass manager
1616
; CHECK-NEXT: LV: Not vectorizing: Cannot prove legality.
1717

0 commit comments

Comments
 (0)