Skip to content

Commit 59f3661

Browse files
committed
Revert "[MacroFusion] Support multiple predicators (#72219)"
This reverts commit d3f6e82. Some code can't be compiled.
1 parent d3f6e82 commit 59f3661

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

llvm/include/llvm/CodeGen/MacroFusion.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#ifndef LLVM_CODEGEN_MACROFUSION_H
1515
#define LLVM_CODEGEN_MACROFUSION_H
1616

17-
#include "llvm/ADT/ArrayRef.h"
17+
#include <functional>
1818
#include <memory>
1919

2020
namespace llvm {
@@ -29,9 +29,10 @@ class SUnit;
2929
/// Check if the instr pair, FirstMI and SecondMI, should be fused
3030
/// together. Given SecondMI, when FirstMI is unspecified, then check if
3131
/// SecondMI may be part of a fused pair at all.
32-
using MacroFusionPredTy = function_ref<bool(
33-
const TargetInstrInfo &TII, const TargetSubtargetInfo &STI,
34-
const MachineInstr *FirstMI, const MachineInstr &SecondMI)>;
32+
using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
33+
const TargetSubtargetInfo &TSI,
34+
const MachineInstr *FirstMI,
35+
const MachineInstr &SecondMI)>;
3536

3637
/// Checks if the number of cluster edges between SU and its predecessors is
3738
/// less than FuseLimit
@@ -47,17 +48,15 @@ bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
4748

4849
/// Create a DAG scheduling mutation to pair instructions back to back
4950
/// for instructions that benefit according to the target-specific
50-
/// predicate functions. shouldScheduleAdjacent will be true if any of the
51-
/// provided predicates are true.
51+
/// shouldScheduleAdjacent predicate function.
5252
std::unique_ptr<ScheduleDAGMutation>
53-
createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
53+
createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
5454

5555
/// Create a DAG scheduling mutation to pair branch instructions with one
5656
/// of their predecessors back to back for instructions that benefit according
57-
/// to the target-specific predicate functions. shouldScheduleAdjacent will be
58-
/// true if any of the provided predicates are true.
57+
/// to the target-specific shouldScheduleAdjacent predicate function.
5958
std::unique_ptr<ScheduleDAGMutation>
60-
createBranchMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
59+
createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
6160

6261
} // end namespace llvm
6362

llvm/lib/CodeGen/MacroFusion.cpp

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,19 @@ namespace {
137137
/// Post-process the DAG to create cluster edges between instrs that may
138138
/// be fused by the processor into a single operation.
139139
class MacroFusion : public ScheduleDAGMutation {
140-
std::vector<MacroFusionPredTy> Predicates;
140+
ShouldSchedulePredTy shouldScheduleAdjacent;
141141
bool FuseBlock;
142142
bool scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU);
143143

144144
public:
145-
MacroFusion(ArrayRef<MacroFusionPredTy> Predicates, bool FuseBlock)
146-
: Predicates(Predicates.begin(), Predicates.end()), FuseBlock(FuseBlock) {
147-
}
145+
MacroFusion(ShouldSchedulePredTy shouldScheduleAdjacent, bool FuseBlock)
146+
: shouldScheduleAdjacent(shouldScheduleAdjacent), FuseBlock(FuseBlock) {}
148147

149148
void apply(ScheduleDAGInstrs *DAGInstrs) override;
150-
151-
bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
152-
const TargetSubtargetInfo &STI,
153-
const MachineInstr *FirstMI,
154-
const MachineInstr &SecondMI);
155149
};
156150

157151
} // end anonymous namespace
158152

159-
bool MacroFusion::shouldScheduleAdjacent(const TargetInstrInfo &TII,
160-
const TargetSubtargetInfo &STI,
161-
const MachineInstr *FirstMI,
162-
const MachineInstr &SecondMI) {
163-
return llvm::any_of(Predicates, [&](MacroFusionPredTy Predicate) {
164-
return Predicate(TII, STI, FirstMI, SecondMI);
165-
});
166-
}
167-
168153
void MacroFusion::apply(ScheduleDAGInstrs *DAG) {
169154
if (FuseBlock)
170155
// 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)
212197
}
213198

214199
std::unique_ptr<ScheduleDAGMutation>
215-
llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates) {
216-
if (EnableMacroFusion)
217-
return std::make_unique<MacroFusion>(Predicates, true);
200+
llvm::createMacroFusionDAGMutation(
201+
ShouldSchedulePredTy shouldScheduleAdjacent) {
202+
if(EnableMacroFusion)
203+
return std::make_unique<MacroFusion>(shouldScheduleAdjacent, true);
218204
return nullptr;
219205
}
220206

221-
std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation(
222-
ArrayRef<MacroFusionPredTy> Predicates) {
223-
if (EnableMacroFusion)
224-
return std::make_unique<MacroFusion>(Predicates, false);
207+
std::unique_ptr<ScheduleDAGMutation>
208+
llvm::createBranchMacroFusionDAGMutation(
209+
ShouldSchedulePredTy shouldScheduleAdjacent) {
210+
if(EnableMacroFusion)
211+
return std::make_unique<MacroFusion>(shouldScheduleAdjacent, false);
225212
return nullptr;
226213
}

llvm/lib/Target/AMDGPU/GCNVOPDUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ namespace {
142142
/// be turned into VOPD instructions
143143
/// Greedily pairs instruction candidates. O(n^2) algorithm.
144144
struct VOPDPairingMutation : ScheduleDAGMutation {
145-
MacroFusionPredTy shouldScheduleAdjacent; // NOLINT: function pointer
145+
ShouldSchedulePredTy shouldScheduleAdjacent; // NOLINT: function pointer
146146

147147
VOPDPairingMutation(
148-
MacroFusionPredTy shouldScheduleAdjacent) // NOLINT: function pointer
148+
ShouldSchedulePredTy shouldScheduleAdjacent) // NOLINT: function pointer
149149
: shouldScheduleAdjacent(shouldScheduleAdjacent) {}
150150

151151
void apply(ScheduleDAGInstrs *DAG) override {

0 commit comments

Comments
 (0)