summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-05-01 06:53:03 +0000
committerCraig Topper <craig.topper@intel.com>2019-05-01 06:53:03 +0000
commitdd66acef96a4fe37d312916586baf39a0c8fc9b2 (patch)
tree6171bdc48ba02c9bbc5c6e3582cdad67cb3a945f /llvm/lib/Target
parent26676c82e88c07f419cffda99c87d44953b41447 (diff)
downloadbcm5719-llvm-dd66acef96a4fe37d312916586baf39a0c8fc9b2.tar.gz
bcm5719-llvm-dd66acef96a4fe37d312916586baf39a0c8fc9b2.zip
[X86FixupLEAs] Hoist the calls to isLEA out of the 3 separate functions and put it in the basic block instruction loop. NFC
Now need to check it 3 different times. Just do it once at the top of the loop. llvm-svn: 359658
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/X86/X86FixupLEAs.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/llvm/lib/Target/X86/X86FixupLEAs.cpp b/llvm/lib/Target/X86/X86FixupLEAs.cpp
index 5f40f5d992e..3cb850a0022 100644
--- a/llvm/lib/Target/X86/X86FixupLEAs.cpp
+++ b/llvm/lib/Target/X86/X86FixupLEAs.cpp
@@ -182,6 +182,11 @@ FixupLEAPass::postRAConvertToLEA(MachineBasicBlock &MBB,
FunctionPass *llvm::createX86FixupLEAs() { return new FixupLEAPass(); }
+static bool isLEA(unsigned Opcode) {
+ return Opcode == X86::LEA16r || Opcode == X86::LEA32r ||
+ Opcode == X86::LEA64r || Opcode == X86::LEA64_32r;
+}
+
bool FixupLEAPass::runOnMachineFunction(MachineFunction &MF) {
if (skipFunction(MF.getFunction()))
return false;
@@ -204,6 +209,9 @@ bool FixupLEAPass::runOnMachineFunction(MachineFunction &MF) {
for (MachineBasicBlock &MBB : MF) {
// First pass. Try to remove or optimize existing LEAs.
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) {
+ if (!isLEA(I->getOpcode()))
+ continue;
+
if (OptIncDec && fixupIncDec(I, MBB))
continue;
@@ -287,11 +295,6 @@ FixupLEAPass::searchBackwards(MachineOperand &p, MachineBasicBlock::iterator &I,
return MachineBasicBlock::iterator();
}
-static inline bool isLEA(const unsigned Opcode) {
- return Opcode == X86::LEA16r || Opcode == X86::LEA32r ||
- Opcode == X86::LEA64r || Opcode == X86::LEA64_32r;
-}
-
static inline bool isInefficientLEAReg(unsigned Reg) {
return Reg == X86::EBP || Reg == X86::RBP ||
Reg == X86::R13D || Reg == X86::R13;
@@ -362,14 +365,11 @@ static inline bool isLEASimpleIncOrDec(MachineInstr &LEA) {
bool FixupLEAPass::fixupIncDec(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) const {
MachineInstr &MI = *I;
- unsigned Opcode = MI.getOpcode();
- if (!isLEA(Opcode))
- return false;
if (isLEASimpleIncOrDec(MI) && TII->isSafeToClobberEFLAGS(MBB, I)) {
unsigned NewOpcode;
bool isINC = MI.getOperand(1 + X86::AddrDisp).getImm() == 1;
- switch (Opcode) {
+ switch (MI.getOpcode()) {
case X86::LEA16r:
NewOpcode = isINC ? X86::INC16r : X86::DEC16r;
break;
@@ -435,8 +435,6 @@ void FixupLEAPass::processInstructionForSlowLEA(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) {
MachineInstr &MI = *I;
const unsigned Opcode = MI.getOpcode();
- if (!isLEA(Opcode))
- return;
const MachineOperand &Dst = MI.getOperand(0);
const MachineOperand &Base = MI.getOperand(1 + X86::AddrBaseReg);
@@ -485,10 +483,7 @@ void FixupLEAPass::processInstructionForSlowLEA(MachineBasicBlock::iterator &I,
MachineInstr *
FixupLEAPass::processInstrForSlow3OpLEA(MachineInstr &MI,
MachineBasicBlock &MBB) {
-
const unsigned LEAOpcode = MI.getOpcode();
- if (!isLEA(LEAOpcode))
- return nullptr;
const MachineOperand &Dst = MI.getOperand(0);
const MachineOperand &Base = MI.getOperand(1 + X86::AddrBaseReg);
OpenPOWER on IntegriCloud