diff --git a/llvm/include/llvm/CodeGen/MacroFusion.h b/llvm/include/llvm/CodeGen/MacroFusion.h index a359fca604260..191c906e9ef6c 100644 --- a/llvm/include/llvm/CodeGen/MacroFusion.h +++ b/llvm/include/llvm/CodeGen/MacroFusion.h @@ -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 -createMacroFusionDAGMutation(ArrayRef 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 -createBranchMacroFusionDAGMutation(ArrayRef Predicates); +createMacroFusionDAGMutation(ArrayRef Predicates, + bool BranchOnly = false); } // end namespace llvm diff --git a/llvm/lib/CodeGen/MacroFusion.cpp b/llvm/lib/CodeGen/MacroFusion.cpp index aff4d95781f45..5bd6ca0978a4b 100644 --- a/llvm/lib/CodeGen/MacroFusion.cpp +++ b/llvm/lib/CodeGen/MacroFusion.cpp @@ -212,15 +212,9 @@ bool MacroFusion::scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU) } std::unique_ptr -llvm::createMacroFusionDAGMutation(ArrayRef Predicates) { +llvm::createMacroFusionDAGMutation(ArrayRef Predicates, + bool BranchOnly) { if (EnableMacroFusion) - return std::make_unique(Predicates, true); - return nullptr; -} - -std::unique_ptr llvm::createBranchMacroFusionDAGMutation( - ArrayRef Predicates) { - if (EnableMacroFusion) - return std::make_unique(Predicates, false); + return std::make_unique(Predicates, !BranchOnly); return nullptr; } diff --git a/llvm/lib/Target/X86/X86MacroFusion.cpp b/llvm/lib/Target/X86/X86MacroFusion.cpp index 82667b8cdbdb8..c0fa9aa703243 100644 --- a/llvm/lib/Target/X86/X86MacroFusion.cpp +++ b/llvm/lib/Target/X86/X86MacroFusion.cpp @@ -68,7 +68,8 @@ static bool shouldScheduleAdjacent(const TargetInstrInfo &TII, namespace llvm { std::unique_ptr createX86MacroFusionDAGMutation() { - return createBranchMacroFusionDAGMutation(shouldScheduleAdjacent); + return createMacroFusionDAGMutation(shouldScheduleAdjacent, + /*BranchOnly=*/true); } } // end namespace llvm