forked from OSchip/llvm-project
[AArch64] Use MachineRegisterInfo instead of LiveIntervals to calculate liveness. NFC.
The CondOpt pass currently uses LiveIntervals to set the dead flag on a def. This patch uses MachineRegisterInfo::use_empty instead as that is equivalent to the def being dead. This removes an instance of LiveIntervals in the pass manager pipeline and saves 3.8% of compile time on llc conpiled for AArch64. Reviewed by Chad Rosier and Zhaoshi. llvm-svn: 235532
This commit is contained in:
parent
c96ee08016
commit
037b700b7f
|
@ -67,6 +67,7 @@
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
|
@ -86,6 +87,7 @@ namespace {
|
||||||
class AArch64ConditionOptimizer : public MachineFunctionPass {
|
class AArch64ConditionOptimizer : public MachineFunctionPass {
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
MachineDominatorTree *DomTree;
|
MachineDominatorTree *DomTree;
|
||||||
|
const MachineRegisterInfo *MRI;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Stores immediate, compare instruction opcode and branch condition (in this
|
// Stores immediate, compare instruction opcode and branch condition (in this
|
||||||
|
@ -116,7 +118,6 @@ void initializeAArch64ConditionOptimizerPass(PassRegistry &);
|
||||||
INITIALIZE_PASS_BEGIN(AArch64ConditionOptimizer, "aarch64-condopt",
|
INITIALIZE_PASS_BEGIN(AArch64ConditionOptimizer, "aarch64-condopt",
|
||||||
"AArch64 CondOpt Pass", false, false)
|
"AArch64 CondOpt Pass", false, false)
|
||||||
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)
|
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)
|
||||||
INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
|
|
||||||
INITIALIZE_PASS_END(AArch64ConditionOptimizer, "aarch64-condopt",
|
INITIALIZE_PASS_END(AArch64ConditionOptimizer, "aarch64-condopt",
|
||||||
"AArch64 CondOpt Pass", false, false)
|
"AArch64 CondOpt Pass", false, false)
|
||||||
|
|
||||||
|
@ -127,8 +128,6 @@ FunctionPass *llvm::createAArch64ConditionOptimizerPass() {
|
||||||
void AArch64ConditionOptimizer::getAnalysisUsage(AnalysisUsage &AU) const {
|
void AArch64ConditionOptimizer::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.addRequired<MachineDominatorTree>();
|
AU.addRequired<MachineDominatorTree>();
|
||||||
AU.addPreserved<MachineDominatorTree>();
|
AU.addPreserved<MachineDominatorTree>();
|
||||||
AU.addRequired<LiveIntervals>();
|
|
||||||
AU.addPreserved<LiveIntervals>();
|
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ MachineInstr *AArch64ConditionOptimizer::findSuitableCompare(
|
||||||
// cmn is an alias for adds with a dead destination register.
|
// cmn is an alias for adds with a dead destination register.
|
||||||
case AArch64::ADDSWri:
|
case AArch64::ADDSWri:
|
||||||
case AArch64::ADDSXri:
|
case AArch64::ADDSXri:
|
||||||
if (I->getOperand(0).isDead())
|
if (MRI->use_empty(I->getOperand(0).getReg()))
|
||||||
return I;
|
return I;
|
||||||
|
|
||||||
DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n');
|
DEBUG(dbgs() << "Destination of cmp is not dead, " << *I << '\n');
|
||||||
|
@ -306,6 +305,7 @@ bool AArch64ConditionOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
||||||
<< "********** Function: " << MF.getName() << '\n');
|
<< "********** Function: " << MF.getName() << '\n');
|
||||||
TII = MF.getSubtarget().getInstrInfo();
|
TII = MF.getSubtarget().getInstrInfo();
|
||||||
DomTree = &getAnalysis<MachineDominatorTree>();
|
DomTree = &getAnalysis<MachineDominatorTree>();
|
||||||
|
MRI = &MF.getRegInfo();
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue