Skip to content

Commit 8d25e98

Browse files
committed
[TTI/{RISCV,AArch64}] Strip redundant unroll prefs
The loop vectorizer emits a llvm.loop.unroll.disable metadata, effectively disabling loop unrolling. Strip redundant code that over-eagerly checks for vector instructions in the loop or the llvm.loop.isvectorized metadata. The patch is non-functional over the full compiler flow.
1 parent 75f81de commit 8d25e98

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4894,25 +4894,6 @@ void AArch64TTIImpl::getUnrollingPreferences(
48944894
// Disable partial & runtime unrolling on -Os.
48954895
UP.PartialOptSizeThreshold = 0;
48964896

4897-
// Scan the loop: don't unroll loops with calls as this could prevent
4898-
// inlining. Don't unroll vector loops either, as they don't benefit much from
4899-
// unrolling.
4900-
for (auto *BB : L->getBlocks()) {
4901-
for (auto &I : *BB) {
4902-
// Don't unroll vectorised loop.
4903-
if (I.getType()->isVectorTy())
4904-
return;
4905-
4906-
if (isa<CallBase>(I)) {
4907-
if (isa<CallInst>(I) || isa<InvokeInst>(I))
4908-
if (const Function *F = cast<CallBase>(I).getCalledFunction())
4909-
if (!isLoweredToCall(F))
4910-
continue;
4911-
return;
4912-
}
4913-
}
4914-
}
4915-
49164897
// Apply subtarget-specific unrolling preferences.
49174898
switch (ST->getProcFamily()) {
49184899
case AArch64Subtarget::AppleA14:

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,20 +2565,11 @@ void RISCVTTIImpl::getUnrollingPreferences(
25652565
if (L->getNumBlocks() > 4)
25662566
return;
25672567

2568-
// Don't unroll vectorized loops, including the remainder loop
2569-
if (getBooleanLoopAttribute(L, "llvm.loop.isvectorized"))
2570-
return;
2571-
25722568
// Scan the loop: don't unroll loops with calls as this could prevent
25732569
// inlining.
25742570
InstructionCost Cost = 0;
25752571
for (auto *BB : L->getBlocks()) {
25762572
for (auto &I : *BB) {
2577-
// Initial setting - Don't unroll loops containing vectorized
2578-
// instructions.
2579-
if (I.getType()->isVectorTy())
2580-
return;
2581-
25822573
if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
25832574
if (const Function *F = cast<CallBase>(I).getCalledFunction()) {
25842575
if (!isLoweredToCall(F))

0 commit comments

Comments
 (0)