[llvm] [CodeGen] TwoAddressInstructionPass: Control NumVisited limit via command line option (PR #100125)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 20:17:55 PDT 2024


https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/100125

>From de65a1f14d8f1987ef34c6ef5b73001deb159a88 Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Tue, 23 Jul 2024 09:54:20 -0400
Subject: [PATCH] [TwoAddressInstructionPass] Have visit limit be a command
 line value

---
 llvm/lib/CodeGen/TwoAddressInstructionPass.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 6f7905c8988dc..fef6330a7cdf0 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -80,6 +80,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<unsigned>
+    MaxVisits("twoaddr-reschedule-visit-limit", cl::Hidden, cl::init(10),
+              cl::desc("Maximum number of rescheduling visits to dependent "
+                       "instructions (0 = no limit)"));
+
 // Limit the number of dataflow edges to traverse when evaluating the benefit
 // of commuting operands.
 static cl::opt<unsigned> MaxDataFlowEdge(
@@ -994,7 +1001,7 @@ bool TwoAddressInstructionImpl::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 (MaxVisits && NumVisited > MaxVisits)
       return false;
     ++NumVisited;
     if (OtherMI.hasUnmodeledSideEffects() || OtherMI.isCall() ||
@@ -1167,7 +1174,7 @@ bool TwoAddressInstructionImpl::rescheduleKillAboveMI(
     // 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 (MaxVisits && NumVisited > MaxVisits)
       return false;
     ++NumVisited;
     if (OtherMI.hasUnmodeledSideEffects() || OtherMI.isCall() ||



More information about the llvm-commits mailing list