Skip to content

Commit 5e41351

Browse files
author
Marek Sedlacek
committed
Changed filter function for a flag to override rotation profitability check
1 parent b180cb9 commit 5e41351

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

llvm/include/llvm/Transforms/Utils/LoopRotationUtils.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ LLVM_ABI bool LoopRotation(
3838
Loop *L, LoopInfo *LI, const TargetTransformInfo *TTI, AssumptionCache *AC,
3939
DominatorTree *DT, ScalarEvolution *SE, MemorySSAUpdater *MSSAU,
4040
const SimplifyQuery &SQ, bool RotationOnly, unsigned Threshold,
41-
bool IsUtilMode, bool PrepareForLTO = false,
42-
function_ref<bool(Loop *, ScalarEvolution *)> ProfitabilityCheck =
43-
[](Loop *, ScalarEvolution *) { return false; });
41+
bool IsUtilMode, bool PrepareForLTO = false, bool ForceRotation=false);
4442

4543
} // namespace llvm
4644

llvm/lib/Transforms/Utils/LoopRotationUtils.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ class LoopRotate {
6969
bool RotationOnly;
7070
bool IsUtilMode;
7171
bool PrepareForLTO;
72-
function_ref<bool(Loop *, ScalarEvolution *)> ProfitabilityCheck;
72+
bool ForceRotation;
7373

7474
public:
7575
LoopRotate(unsigned MaxHeaderSize, LoopInfo *LI,
7676
const TargetTransformInfo *TTI, AssumptionCache *AC,
7777
DominatorTree *DT, ScalarEvolution *SE, MemorySSAUpdater *MSSAU,
7878
const SimplifyQuery &SQ, bool RotationOnly, bool IsUtilMode,
7979
bool PrepareForLTO,
80-
function_ref<bool(Loop *, ScalarEvolution *)> ProfitabilityCheck)
80+
bool ForceRotation)
8181
: MaxHeaderSize(MaxHeaderSize), LI(LI), TTI(TTI), AC(AC), DT(DT), SE(SE),
8282
MSSAU(MSSAU), SQ(SQ), RotationOnly(RotationOnly),
8383
IsUtilMode(IsUtilMode), PrepareForLTO(PrepareForLTO),
84-
ProfitabilityCheck(ProfitabilityCheck) {}
84+
ForceRotation(ForceRotation) {}
8585
bool processLoop(Loop *L);
8686

8787
private:
@@ -445,7 +445,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
445445
// latch was just simplified. Or if we think it will be profitable.
446446
if (L->isLoopExiting(OrigLatch) && !SimplifiedLatch &&
447447
IsUtilMode == false && !profitableToRotateLoopExitingLatch(L) &&
448-
!canRotateDeoptimizingLatchExit(L) && !ProfitabilityCheck(L, SE))
448+
!canRotateDeoptimizingLatchExit(L) && !ForceRotation)
449449
return Rotated;
450450

451451
// Check size of original header and reject loop if it is very big or we can't
@@ -1061,9 +1061,8 @@ bool llvm::LoopRotation(
10611061
DominatorTree *DT, ScalarEvolution *SE, MemorySSAUpdater *MSSAU,
10621062
const SimplifyQuery &SQ, bool RotationOnly = true,
10631063
unsigned Threshold = unsigned(-1), bool IsUtilMode = true,
1064-
bool PrepareForLTO,
1065-
function_ref<bool(Loop *, ScalarEvolution *)> ProfitabilityCheck) {
1064+
bool PrepareForLTO, bool ForceRotation) {
10661065
LoopRotate LR(Threshold, LI, TTI, AC, DT, SE, MSSAU, SQ, RotationOnly,
1067-
IsUtilMode, PrepareForLTO, ProfitabilityCheck);
1066+
IsUtilMode, PrepareForLTO, ForceRotation);
10681067
return LR.processLoop(L);
10691068
}

llvm/lib/Transforms/Utils/LoopUnroll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
564564
/*MemorySSAUpdater*/ nullptr, SQ,
565565
/*RotationOnly*/ false, /*Threshold*/ 16,
566566
/*IsUtilMode*/ false, /*PrepareForLTO*/ false,
567-
[](Loop *, ScalarEvolution *) { return true; });
567+
/*ForceRotation*/ true);
568568
}
569569
if (LoopRotated) {
570570
// Loop was rotated, try unrolling.

0 commit comments

Comments
 (0)