Skip to content

Commit d8e6d74

Browse files
authored
[LV] Consider EVL legality for TTI tail folding preference (#144790)
1 parent b963701 commit d8e6d74

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,36 +1364,33 @@ 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.
13801378
// FIXME: Investigate opportunity for fixed vector factor.
13811379
bool EVLIsLegal = UserIC <= 1 && IsScalableVF &&
13821380
TTI.hasActiveVectorLength() && !EnableVPlanNativePath;
1383-
if (!EVLIsLegal) {
1384-
// If for some reason EVL mode is unsupported, fallback to
1385-
// DataWithoutLaneMask to try to vectorize the loop with folded tail
1386-
// in a generic way.
1387-
ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
1388-
TailFoldingStyle::DataWithoutLaneMask};
1389-
LLVM_DEBUG(
1390-
dbgs()
1391-
<< "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"));
1396-
}
1381+
if (EVLIsLegal)
1382+
return;
1383+
// If for some reason EVL mode is unsupported, fallback to
1384+
// DataWithoutLaneMask to try to vectorize the loop with folded tail
1385+
// in a generic way.
1386+
ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
1387+
TailFoldingStyle::DataWithoutLaneMask};
1388+
LLVM_DEBUG(
1389+
dbgs() << "LV: Preference for VP intrinsics indicated. Will "
1390+
"not try to generate VP Intrinsics "
1391+
<< (UserIC > 1
1392+
? "since interleave count specified is greater than 1.\n"
1393+
: "due to non-interleaving reasons.\n"));
13971394
}
13981395

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

0 commit comments

Comments
 (0)