diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -843,6 +843,9 @@ bool enableEarlyIfConversion() const override; + void getPostRAMutations( + std::vector> &Mutations) const; + AntiDepBreakMode getAntiDepBreakMode() const override { return TargetSubtargetInfo::ANTIDEP_CRITICAL; } diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -14,6 +14,7 @@ #include "X86CallLowering.h" #include "X86LegalizerInfo.h" +#include "X86MacroFusion.h" #include "X86RegisterBankInfo.h" #include "X86Subtarget.h" #include "MCTargetDesc/X86BaseInfo.h" @@ -366,3 +367,8 @@ bool X86Subtarget::enableEarlyIfConversion() const { return hasCMov() && X86EarlyIfConv; } + +void X86Subtarget::getPostRAMutations( + std::vector> &Mutations) const { + Mutations.push_back(createX86MacroFusionDAGMutation()); +} diff --git a/llvm/test/CodeGen/X86/testb-je-fusion.ll b/llvm/test/CodeGen/X86/testb-je-fusion.ll --- a/llvm/test/CodeGen/X86/testb-je-fusion.ll +++ b/llvm/test/CodeGen/X86/testb-je-fusion.ll @@ -45,8 +45,8 @@ ; BRANCHFUSION_POSTRA-LABEL: macrofuse_test_je: ; BRANCHFUSION_POSTRA: # %bb.0: # %entry ; BRANCHFUSION_POSTRA-NEXT: xorl %eax, %eax -; BRANCHFUSION_POSTRA-NEXT: testl $512, %edi # imm = 0x200 ; BRANCHFUSION_POSTRA-NEXT: movb $1, (%rsi) +; BRANCHFUSION_POSTRA-NEXT: testl $512, %edi # imm = 0x200 ; BRANCHFUSION_POSTRA-NEXT: je .LBB0_2 ; BRANCHFUSION_POSTRA-NEXT: # %bb.1: # %if.then ; BRANCHFUSION_POSTRA-NEXT: movl $1, %eax @@ -105,8 +105,8 @@ ; ; BRANCHFUSION_POSTRA-LABEL: macrofuse_cmp_je: ; BRANCHFUSION_POSTRA: # %bb.0: # %entry -; BRANCHFUSION_POSTRA-NEXT: cmpl $512, %edi # imm = 0x200 ; BRANCHFUSION_POSTRA-NEXT: movb $1, (%rsi) +; BRANCHFUSION_POSTRA-NEXT: cmpl $512, %edi # imm = 0x200 ; BRANCHFUSION_POSTRA-NEXT: je .LBB1_1 ; BRANCHFUSION_POSTRA-NEXT: # %bb.2: # %if.then ; BRANCHFUSION_POSTRA-NEXT: movl $1, %eax