[PATCH] D140540: [MachineTraceMetrics] Add local strategy
Anton Sidorenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 22 02:55:12 PST 2022
asi-sc created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
asi-sc requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This strategy makes each trace local to the basic block. For in-order cores some
heuristics work better when we do local decisions. For example, MachineCombiner
may expect that instructions outside the current basic block do not lengthen
the critical path when we execute instructions in order or the core has a
small re-order buffer.
This patch only introduce the strategy, real use-case is added in the further
pathes.
Depends on D140539 <https://reviews.llvm.org/D140539>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140540
Files:
llvm/include/llvm/CodeGen/MachineTraceMetrics.h
llvm/lib/CodeGen/MachineTraceMetrics.cpp
Index: llvm/lib/CodeGen/MachineTraceMetrics.cpp
===================================================================
--- llvm/lib/CodeGen/MachineTraceMetrics.cpp
+++ llvm/lib/CodeGen/MachineTraceMetrics.cpp
@@ -318,6 +318,21 @@
: MachineTraceMetrics::Ensemble(mtm) {}
};
+// LocalEnsemble - Pick only the current basic block for the trace and do not
+// choose any predecessors/successors.
+class LocalEnsemble : public MachineTraceMetrics::Ensemble {
+ const char *getName() const override { return "Local"; }
+ const MachineBasicBlock *pickTracePred(const MachineBasicBlock *) override {
+ return nullptr;
+ };
+ const MachineBasicBlock *pickTraceSucc(const MachineBasicBlock *) override {
+ return nullptr;
+ };
+
+public:
+ LocalEnsemble(MachineTraceMetrics *MTM)
+ : MachineTraceMetrics::Ensemble(MTM) {}
+};
} // end anonymous namespace
// Select the preferred predecessor for MBB.
@@ -391,6 +406,8 @@
switch (strategy) {
case MachineTraceStrategy::TS_MinInstrCount:
return (E = new MinInstrCountEnsemble(this));
+ case MachineTraceStrategy::TS_Local:
+ return (E = new LocalEnsemble(this));
default: llvm_unreachable("Invalid trace strategy enum");
}
}
Index: llvm/include/llvm/CodeGen/MachineTraceMetrics.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineTraceMetrics.h
+++ llvm/include/llvm/CodeGen/MachineTraceMetrics.h
@@ -86,6 +86,10 @@
enum class MachineTraceStrategy {
/// Select the trace through a block that has the fewest instructions.
TS_MinInstrCount,
+ /// Select the trace that contains only the current basic block. For instance,
+ /// this strategy can be used by MachineCombiner to make better decisions when
+ /// we estimate critical path for in-order cores.
+ TS_Local,
TS_NumStrategies
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140540.484779.patch
Type: text/x-patch
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221222/63b736a4/attachment.bin>
More information about the llvm-commits
mailing list