From 17858ce6f3d24f994f6ad8c899bfa4eed39f739d Mon Sep 17 00:00:00 2001 From: Wang Pengcheng Date: Fri, 22 Dec 2023 16:31:38 +0800 Subject: [PATCH] [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`. --- llvm/include/llvm/CodeGen/MacroFusion.h | 12 ++++-------- llvm/lib/CodeGen/MacroFusion.cpp | 12 +++--------- llvm/lib/Target/X86/X86MacroFusion.cpp | 3 ++- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MacroFusion.h b/llvm/include/llvm/CodeGen/MacroFusion.h index a359fca6042600..191c906e9ef6c6 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 aff4d95781f45c..5bd6ca0978a4b1 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 82667b8cdbdb87..c0fa9aa7032437 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