[llvm] [CodeGen] TwoAddressInstructionPass - Control NumVisited limit via command line option (PR #84845)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 15:28:51 PDT 2024
https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/84845
Pulled out of comment made on #80627 - to simplify further investigation into visit limits.
We still need test coverage - we can either continue this patch here or @AtariDreams - I'm happy for this to be added to #80627
>From 89cd5695700e933255780b89489bd36793730640 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
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 ebacbc420f8580..afbd8d461a918a 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<unsigned> 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<unsigned> 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() ||
More information about the llvm-commits
mailing list