From 7e062c9b1f9ad02010127aa0800abbfcd4fb804c Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Mon, 1 Apr 2019 13:48:50 +0000 Subject: [PATCH] [X86] Make post-ra scheduling macrofusion-aware. Subscribers: MatzeB, arsenm, jvesely, nhaehnle, hiraditya, javed.absar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59688 llvm-svn: 357384 --- llvm/lib/Target/X86/X86Subtarget.cpp | 6 ++++++ llvm/lib/Target/X86/X86Subtarget.h | 3 +++ llvm/test/CodeGen/X86/testb-je-fusion.ll | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index d6ffad0137f0..177fde45911a 100644 --- 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 @@ const RegisterBankInfo *X86Subtarget::getRegBankInfo() const { bool X86Subtarget::enableEarlyIfConversion() const { return hasCMov() && X86EarlyIfConv; } + +void X86Subtarget::getPostRAMutations( + std::vector> &Mutations) const { + Mutations.push_back(createX86MacroFusionDAGMutation()); +} diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index 2bd36d42c5c4..b49912bae690 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -843,6 +843,9 @@ public: bool enableEarlyIfConversion() const override; + void getPostRAMutations( + std::vector> &Mutations) const; + AntiDepBreakMode getAntiDepBreakMode() const override { return TargetSubtargetInfo::ANTIDEP_CRITICAL; } diff --git a/llvm/test/CodeGen/X86/testb-je-fusion.ll b/llvm/test/CodeGen/X86/testb-je-fusion.ll index 538baea0fbab..6bda84861856 100644 --- a/llvm/test/CodeGen/X86/testb-je-fusion.ll +++ b/llvm/test/CodeGen/X86/testb-je-fusion.ll @@ -45,8 +45,8 @@ define i32 @macrofuse_test_je(i32 %flags, i8* %p) nounwind { ; 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 @@ define i32 @macrofuse_cmp_je(i32 %flags, i8* %p) nounwind { ; ; 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