@@ -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.
8289static 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