[llvm-branch-commits] [llvm] 9c8660e - Revert "[MacroFusion] Support multiple predicators (#72219)"
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 11 19:20:56 PST 2023
Author: Wang Pengcheng
Date: 2023-12-12T11:20:52+08:00
New Revision: 9c8660ebb83e26f94e487c4183433379204d29ac
URL: https://github.com/llvm/llvm-project/commit/9c8660ebb83e26f94e487c4183433379204d29ac
DIFF: https://github.com/llvm/llvm-project/commit/9c8660ebb83e26f94e487c4183433379204d29ac.diff
LOG: Revert "[MacroFusion] Support multiple predicators (#72219)"
This reverts commit d3f6e82a6a562e3288a6fc0970d324073996c16d.
Added:
Modified:
llvm/include/llvm/CodeGen/MacroFusion.h
llvm/lib/CodeGen/MacroFusion.cpp
llvm/lib/Target/AMDGPU/GCNVOPDUtils.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MacroFusion.h b/llvm/include/llvm/CodeGen/MacroFusion.h
index 41a027ea06696b..ea2c7a5faae385 100644
--- a/llvm/include/llvm/CodeGen/MacroFusion.h
+++ b/llvm/include/llvm/CodeGen/MacroFusion.h
@@ -14,7 +14,7 @@
#ifndef LLVM_CODEGEN_MACROFUSION_H
#define LLVM_CODEGEN_MACROFUSION_H
-#include "llvm/ADT/ArrayRef.h"
+#include <functional>
#include <memory>
namespace llvm {
@@ -29,9 +29,10 @@ class SUnit;
/// Check if the instr pair, FirstMI and SecondMI, should be fused
/// together. Given SecondMI, when FirstMI is unspecified, then check if
/// SecondMI may be part of a fused pair at all.
-using MacroFusionPredTy = function_ref<bool(
- const TargetInstrInfo &TII, const TargetSubtargetInfo &STI,
- const MachineInstr *FirstMI, const MachineInstr &SecondMI)>;
+using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
+ const TargetSubtargetInfo &TSI,
+ const MachineInstr *FirstMI,
+ const MachineInstr &SecondMI)>;
/// Checks if the number of cluster edges between SU and its predecessors is
/// less than FuseLimit
@@ -47,17 +48,15 @@ bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
/// Create a DAG scheduling mutation to pair instructions back to back
/// for instructions that benefit according to the target-specific
-/// predicate functions. shouldScheduleAdjacent will be true if any of the
-/// provided predicates are true.
+/// shouldScheduleAdjacent predicate function.
std::unique_ptr<ScheduleDAGMutation>
-createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
+createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
/// Create a DAG scheduling mutation to pair branch instructions with one
/// of their predecessors back to back for instructions that benefit according
-/// to the target-specific predicate functions. shouldScheduleAdjacent will be
-/// true if any of the provided predicates are true.
+/// to the target-specific shouldScheduleAdjacent predicate function.
std::unique_ptr<ScheduleDAGMutation>
-createBranchMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
+createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
} // end namespace llvm
diff --git a/llvm/lib/CodeGen/MacroFusion.cpp b/llvm/lib/CodeGen/MacroFusion.cpp
index aff4d95781f45c..fa5df68b8abcc0 100644
--- a/llvm/lib/CodeGen/MacroFusion.cpp
+++ b/llvm/lib/CodeGen/MacroFusion.cpp
@@ -137,34 +137,19 @@ namespace {
/// Post-process the DAG to create cluster edges between instrs that may
/// be fused by the processor into a single operation.
class MacroFusion : public ScheduleDAGMutation {
- std::vector<MacroFusionPredTy> Predicates;
+ ShouldSchedulePredTy shouldScheduleAdjacent;
bool FuseBlock;
bool scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU);
public:
- MacroFusion(ArrayRef<MacroFusionPredTy> Predicates, bool FuseBlock)
- : Predicates(Predicates.begin(), Predicates.end()), FuseBlock(FuseBlock) {
- }
+ MacroFusion(ShouldSchedulePredTy shouldScheduleAdjacent, bool FuseBlock)
+ : shouldScheduleAdjacent(shouldScheduleAdjacent), FuseBlock(FuseBlock) {}
void apply(ScheduleDAGInstrs *DAGInstrs) override;
-
- bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
- const TargetSubtargetInfo &STI,
- const MachineInstr *FirstMI,
- const MachineInstr &SecondMI);
};
} // end anonymous namespace
-bool MacroFusion::shouldScheduleAdjacent(const TargetInstrInfo &TII,
- const TargetSubtargetInfo &STI,
- const MachineInstr *FirstMI,
- const MachineInstr &SecondMI) {
- return llvm::any_of(Predicates, [&](MacroFusionPredTy Predicate) {
- return Predicate(TII, STI, FirstMI, SecondMI);
- });
-}
-
void MacroFusion::apply(ScheduleDAGInstrs *DAG) {
if (FuseBlock)
// For each of the SUnits in the scheduling block, try to fuse the instr in
@@ -212,15 +197,17 @@ bool MacroFusion::scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU)
}
std::unique_ptr<ScheduleDAGMutation>
-llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates) {
- if (EnableMacroFusion)
- return std::make_unique<MacroFusion>(Predicates, true);
+llvm::createMacroFusionDAGMutation(
+ ShouldSchedulePredTy shouldScheduleAdjacent) {
+ if(EnableMacroFusion)
+ return std::make_unique<MacroFusion>(shouldScheduleAdjacent, true);
return nullptr;
}
-std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation(
- ArrayRef<MacroFusionPredTy> Predicates) {
- if (EnableMacroFusion)
- return std::make_unique<MacroFusion>(Predicates, false);
+std::unique_ptr<ScheduleDAGMutation>
+llvm::createBranchMacroFusionDAGMutation(
+ ShouldSchedulePredTy shouldScheduleAdjacent) {
+ if(EnableMacroFusion)
+ return std::make_unique<MacroFusion>(shouldScheduleAdjacent, false);
return nullptr;
}
diff --git a/llvm/lib/Target/AMDGPU/GCNVOPDUtils.cpp b/llvm/lib/Target/AMDGPU/GCNVOPDUtils.cpp
index 0bddeeef9e9b1a..29c9b9ccf27614 100644
--- a/llvm/lib/Target/AMDGPU/GCNVOPDUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNVOPDUtils.cpp
@@ -142,10 +142,10 @@ namespace {
/// be turned into VOPD instructions
/// Greedily pairs instruction candidates. O(n^2) algorithm.
struct VOPDPairingMutation : ScheduleDAGMutation {
- MacroFusionPredTy shouldScheduleAdjacent; // NOLINT: function pointer
+ ShouldSchedulePredTy shouldScheduleAdjacent; // NOLINT: function pointer
VOPDPairingMutation(
- MacroFusionPredTy shouldScheduleAdjacent) // NOLINT: function pointer
+ ShouldSchedulePredTy shouldScheduleAdjacent) // NOLINT: function pointer
: shouldScheduleAdjacent(shouldScheduleAdjacent) {}
void apply(ScheduleDAGInstrs *DAG) override {
More information about the llvm-branch-commits
mailing list