forked from OSchip/llvm-project
MachineCSE: Add a target query for the LookAheadLimit heurisitic
This is used to determine whether or not to CSE physical register defs. Differential Revision: http://reviews.llvm.org/D9472 llvm-svn: 236923
This commit is contained in:
parent
d54fb89901
commit
f01af29f01
|
@ -1235,6 +1235,14 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Return the value to use for the MachineCSE's LookAheadLimit,
|
||||||
|
/// which is a heuristic used for CSE'ing phys reg defs.
|
||||||
|
virtual unsigned getMachineCSELookAheadLimit () const {
|
||||||
|
// The default lookahead is small to prevent unprofitable quadratic
|
||||||
|
// behavior.
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int CallFrameSetupOpcode, CallFrameDestroyOpcode;
|
int CallFrameSetupOpcode, CallFrameDestroyOpcode;
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace {
|
||||||
MachineRegisterInfo *MRI;
|
MachineRegisterInfo *MRI;
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification
|
static char ID; // Pass identification
|
||||||
MachineCSE() : MachineFunctionPass(ID), LookAheadLimit(5), CurrVN(0) {
|
MachineCSE() : MachineFunctionPass(ID), LookAheadLimit(0), CurrVN(0) {
|
||||||
initializeMachineCSEPass(*PassRegistry::getPassRegistry());
|
initializeMachineCSEPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const unsigned LookAheadLimit;
|
unsigned LookAheadLimit;
|
||||||
typedef RecyclingAllocator<BumpPtrAllocator,
|
typedef RecyclingAllocator<BumpPtrAllocator,
|
||||||
ScopedHashTableVal<MachineInstr*, unsigned> > AllocatorTy;
|
ScopedHashTableVal<MachineInstr*, unsigned> > AllocatorTy;
|
||||||
typedef ScopedHashTable<MachineInstr*, unsigned,
|
typedef ScopedHashTable<MachineInstr*, unsigned,
|
||||||
|
@ -716,5 +716,6 @@ bool MachineCSE::runOnMachineFunction(MachineFunction &MF) {
|
||||||
MRI = &MF.getRegInfo();
|
MRI = &MF.getRegInfo();
|
||||||
AA = &getAnalysis<AliasAnalysis>();
|
AA = &getAnalysis<AliasAnalysis>();
|
||||||
DT = &getAnalysis<MachineDominatorTree>();
|
DT = &getAnalysis<MachineDominatorTree>();
|
||||||
|
LookAheadLimit = TII->getMachineCSELookAheadLimit();
|
||||||
return PerformCSE(DT->getRootNode());
|
return PerformCSE(DT->getRootNode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,8 @@ public:
|
||||||
bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
|
bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
|
||||||
unsigned Reg, MachineRegisterInfo *MRI) const final;
|
unsigned Reg, MachineRegisterInfo *MRI) const final;
|
||||||
|
|
||||||
|
unsigned getMachineCSELookAheadLimit() const override { return 500; }
|
||||||
|
|
||||||
bool isSALU(uint16_t Opcode) const {
|
bool isSALU(uint16_t Opcode) const {
|
||||||
return get(Opcode).TSFlags & SIInstrFlags::SALU;
|
return get(Opcode).TSFlags & SIInstrFlags::SALU;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue