Skip to content

Commit 89cd569

Browse files
committed
[CodeGen] TwoAddressInstructionPass - Control NumVisited limit via command line option
Pulled out of comment made on llvm#80627
1 parent c93c76b commit 89cd569

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ EnableRescheduling("twoaddr-reschedule",
7777
cl::desc("Coalesce copies by rescheduling (default=true)"),
7878
cl::init(true), cl::Hidden);
7979

80+
// Limit the number of rescheduling visits to dependent instructions.
81+
// FIXME: Arbitrary limit to reduce compile time cost.
82+
static cl::opt<unsigned> MaxVisits(
83+
"twoaddr-visit-limit", cl::Hidden, cl::init(10),
84+
cl::desc(
85+
"Maximum number of rescheduling visits to dependent instructions"));
86+
8087
// Limit the number of dataflow edges to traverse when evaluating the benefit
8188
// of commuting operands.
8289
static cl::opt<unsigned> MaxDataFlowEdge(
@@ -921,7 +928,7 @@ bool TwoAddressInstructionPass::rescheduleMIBelowKill(
921928
// Debug or pseudo instructions cannot be counted against the limit.
922929
if (OtherMI.isDebugOrPseudoInstr())
923930
continue;
924-
if (NumVisited > 10) // FIXME: Arbitrary limit to reduce compile time cost.
931+
if (NumVisited > MaxVisits)
925932
return false;
926933
++NumVisited;
927934
if (OtherMI.hasUnmodeledSideEffects() || OtherMI.isCall() ||
@@ -1087,14 +1094,14 @@ bool TwoAddressInstructionPass::rescheduleKillAboveMI(
10871094
}
10881095
}
10891096

1090-
// Check if the reschedule will not break depedencies.
1097+
// Check if the reschedule will not break dependencies.
10911098
unsigned NumVisited = 0;
10921099
for (MachineInstr &OtherMI :
10931100
make_range(mi, MachineBasicBlock::iterator(KillMI))) {
10941101
// Debug or pseudo instructions cannot be counted against the limit.
10951102
if (OtherMI.isDebugOrPseudoInstr())
10961103
continue;
1097-
if (NumVisited > 10) // FIXME: Arbitrary limit to reduce compile time cost.
1104+
if (NumVisited > MaxVisits)
10981105
return false;
10991106
++NumVisited;
11001107
if (OtherMI.hasUnmodeledSideEffects() || OtherMI.isCall() ||

0 commit comments

Comments
 (0)