From 89cd5695700e933255780b89489bd36793730640 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 11 Mar 2024 22:20:44 +0000 Subject: [PATCH] [CodeGen] TwoAddressInstructionPass - Control NumVisited limit via command line option Pulled out of comment made on #80627 --- llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index ebacbc420f858..afbd8d461a918 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -77,6 +77,13 @@ EnableRescheduling("twoaddr-reschedule", cl::desc("Coalesce copies by rescheduling (default=true)"), cl::init(true), cl::Hidden); +// Limit the number of rescheduling visits to dependent instructions. +// FIXME: Arbitrary limit to reduce compile time cost. +static cl::opt MaxVisits( + "twoaddr-visit-limit", cl::Hidden, cl::init(10), + cl::desc( + "Maximum number of rescheduling visits to dependent instructions")); + // Limit the number of dataflow edges to traverse when evaluating the benefit // of commuting operands. static cl::opt MaxDataFlowEdge( @@ -921,7 +928,7 @@ bool TwoAddressInstructionPass::rescheduleMIBelowKill( // Debug or pseudo instructions cannot be counted against the limit. if (OtherMI.isDebugOrPseudoInstr()) continue; - if (NumVisited > 10) // FIXME: Arbitrary limit to reduce compile time cost. + if (NumVisited > MaxVisits) return false; ++NumVisited; if (OtherMI.hasUnmodeledSideEffects() || OtherMI.isCall() || @@ -1087,14 +1094,14 @@ bool TwoAddressInstructionPass::rescheduleKillAboveMI( } } - // Check if the reschedule will not break depedencies. + // Check if the reschedule will not break dependencies. unsigned NumVisited = 0; for (MachineInstr &OtherMI : make_range(mi, MachineBasicBlock::iterator(KillMI))) { // Debug or pseudo instructions cannot be counted against the limit. if (OtherMI.isDebugOrPseudoInstr()) continue; - if (NumVisited > 10) // FIXME: Arbitrary limit to reduce compile time cost. + if (NumVisited > MaxVisits) return false; ++NumVisited; if (OtherMI.hasUnmodeledSideEffects() || OtherMI.isCall() ||