Skip to content

Commit

Permalink
[MacroFusion] Remove createBranchMacroFusionDAGMutation (#76209)
Browse files Browse the repository at this point in the history
Instead, we add a `BranchOnly` parameter to indicate that only
branches with its predecessors will be fused.

X86 is the only user of `createBranchMacroFusionDAGMutation`.
  • Loading branch information
wangpc-pp committed Dec 22, 2023
1 parent 06a9c67 commit 17858ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
12 changes: 4 additions & 8 deletions llvm/include/llvm/CodeGen/MacroFusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
/// for instructions that benefit according to the target-specific
/// predicate functions. shouldScheduleAdjacent will be true if any of the
/// provided predicates are true.
/// If BranchOnly is true, only branch instructions with one of their
/// predecessors will be fused.
std::unique_ptr<ScheduleDAGMutation>
createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);

/// 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.
std::unique_ptr<ScheduleDAGMutation>
createBranchMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates);
createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates,
bool BranchOnly = false);

} // end namespace llvm

Expand Down
12 changes: 3 additions & 9 deletions llvm/lib/CodeGen/MacroFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,9 @@ bool MacroFusion::scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU)
}

std::unique_ptr<ScheduleDAGMutation>
llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates) {
llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates,
bool BranchOnly) {
if (EnableMacroFusion)
return std::make_unique<MacroFusion>(Predicates, true);
return nullptr;
}

std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation(
ArrayRef<MacroFusionPredTy> Predicates) {
if (EnableMacroFusion)
return std::make_unique<MacroFusion>(Predicates, false);
return std::make_unique<MacroFusion>(Predicates, !BranchOnly);
return nullptr;
}
3 changes: 2 additions & 1 deletion llvm/lib/Target/X86/X86MacroFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
namespace llvm {

std::unique_ptr<ScheduleDAGMutation> createX86MacroFusionDAGMutation() {
return createBranchMacroFusionDAGMutation(shouldScheduleAdjacent);
return createMacroFusionDAGMutation(shouldScheduleAdjacent,
/*BranchOnly=*/true);
}

} // end namespace llvm

0 comments on commit 17858ce

Please sign in to comment.