Skip to content

Commit fe476ab

Browse files
committed
[LV] Consider EVL legality for TTI tail folding preference
1 parent 298f1c2 commit fe476ab

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,16 +1364,14 @@ class LoopVectorizationCostModel {
13641364
return;
13651365
}
13661366

1367-
if (!ForceTailFoldingStyle.getNumOccurrences()) {
1368-
ChosenTailFoldingStyle = {
1369-
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
1370-
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
1371-
return;
1372-
}
1367+
// Default to TTI preference, but allow command line override.
1368+
ChosenTailFoldingStyle = {
1369+
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
1370+
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
1371+
if (ForceTailFoldingStyle.getNumOccurrences())
1372+
ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
1373+
ForceTailFoldingStyle.getValue()};
13731374

1374-
// Set styles when forced.
1375-
ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
1376-
ForceTailFoldingStyle.getValue()};
13771375
if (ForceTailFoldingStyle != TailFoldingStyle::DataWithEVL)
13781376
return;
13791377
// Override forced styles if needed.
@@ -1382,20 +1380,19 @@ class LoopVectorizationCostModel {
13821380
bool EVLIsLegal = UserIC <= 1 && IsScalableVF &&
13831381
TTI.hasActiveVectorLength(0, nullptr, Align()) &&
13841382
!EnableVPlanNativePath;
1385-
if (!EVLIsLegal) {
1386-
// If for some reason EVL mode is unsupported, fallback to
1387-
// DataWithoutLaneMask to try to vectorize the loop with folded tail
1388-
// in a generic way.
1389-
ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
1390-
TailFoldingStyle::DataWithoutLaneMask};
1391-
LLVM_DEBUG(
1392-
dbgs()
1393-
<< "LV: Preference for VP intrinsics indicated. Will "
1394-
"not try to generate VP Intrinsics "
1395-
<< (UserIC > 1
1396-
? "since interleave count specified is greater than 1.\n"
1397-
: "due to non-interleaving reasons.\n"));
1398-
}
1383+
if (EVLIsLegal)
1384+
return;
1385+
// If for some reason EVL mode is unsupported, fallback to
1386+
// DataWithoutLaneMask to try to vectorize the loop with folded tail
1387+
// in a generic way.
1388+
ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
1389+
TailFoldingStyle::DataWithoutLaneMask};
1390+
LLVM_DEBUG(
1391+
dbgs() << "LV: Preference for VP intrinsics indicated. Will "
1392+
"not try to generate VP Intrinsics "
1393+
<< (UserIC > 1
1394+
? "since interleave count specified is greater than 1.\n"
1395+
: "due to non-interleaving reasons.\n"));
13991396
}
14001397

14011398
/// Returns true if all loop blocks should be masked to fold tail loop.

0 commit comments

Comments
 (0)