Skip to content

Commit 17858ce

Browse files
authored
[MacroFusion] Remove createBranchMacroFusionDAGMutation (#76209)
Instead, we add a `BranchOnly` parameter to indicate that only branches with its predecessors will be fused. X86 is the only user of `createBranchMacroFusionDAGMutation`.
1 parent 06a9c67 commit 17858ce

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

llvm/include/llvm/CodeGen/MacroFusion.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,11 @@ bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
5050
/// for instructions that benefit according to the target-specific
5151
/// predicate functions. shouldScheduleAdjacent will be true if any of the
5252
/// provided predicates are true.
53+
/// If BranchOnly is true, only branch instructions with one of their
54+
/// predecessors will be fused.
5355
std::unique_ptr<ScheduleDAGMutation>
54-
createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
55-
56-
/// Create a DAG scheduling mutation to pair branch instructions with one
57-
/// of their predecessors back to back for instructions that benefit according
58-
/// to the target-specific predicate functions. shouldScheduleAdjacent will be
59-
/// true if any of the provided predicates are true.
60-
std::unique_ptr<ScheduleDAGMutation>
61-
createBranchMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
56+
createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates,
57+
bool BranchOnly = false);
6258

6359
} // end namespace llvm
6460

llvm/lib/CodeGen/MacroFusion.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,9 @@ bool MacroFusion::scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU)
212212
}
213213

214214
std::unique_ptr<ScheduleDAGMutation>
215-
llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates) {
215+
llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates,
216+
bool BranchOnly) {
216217
if (EnableMacroFusion)
217-
return std::make_unique<MacroFusion>(Predicates, true);
218-
return nullptr;
219-
}
220-
221-
std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation(
222-
ArrayRef<MacroFusionPredTy> Predicates) {
223-
if (EnableMacroFusion)
224-
return std::make_unique<MacroFusion>(Predicates, false);
218+
return std::make_unique<MacroFusion>(Predicates, !BranchOnly);
225219
return nullptr;
226220
}

llvm/lib/Target/X86/X86MacroFusion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
6868
namespace llvm {
6969

7070
std::unique_ptr<ScheduleDAGMutation> createX86MacroFusionDAGMutation() {
71-
return createBranchMacroFusionDAGMutation(shouldScheduleAdjacent);
71+
return createMacroFusionDAGMutation(shouldScheduleAdjacent,
72+
/*BranchOnly=*/true);
7273
}
7374

7475
} // end namespace llvm

0 commit comments

Comments
 (0)