diff --git a/llvm/lib/Target/X86/X86OptimizeLEAs.cpp b/llvm/lib/Target/X86/X86OptimizeLEAs.cpp --- a/llvm/lib/Target/X86/X86OptimizeLEAs.cpp +++ b/llvm/lib/Target/X86/X86OptimizeLEAs.cpp @@ -435,6 +435,10 @@ MRI->getRegClass(Last.getOperand(0).getReg())) return false; + // We don't deal with physical registers. + if (Register::isPhysicalRegister(Last.getOperand(0).getReg())) + return false; + // Get new address displacement. AddrDispShift = getAddrDispShift(Last, 1, First, 1); @@ -455,18 +459,11 @@ MemOpNo += X86II::getOperandBias(Desc); - // If the address base of the use instruction is not the LEA def register - + // If this use does not come from the address base of the use instruction, // the LEA is not replaceable. - if (!isIdenticalOp(MI.getOperand(MemOpNo + X86::AddrBaseReg), MO)) + if (&MO != &MI.getOperand(MemOpNo + X86::AddrBaseReg)) return false; - // If the LEA def register is used as any other operand of the use - // instruction - the LEA is not replaceable. - for (unsigned i = 0; i < MI.getNumOperands(); i++) - if (i != (unsigned)(MemOpNo + X86::AddrBaseReg) && - isIdenticalOp(MI.getOperand(i), MO)) - return false; - // Check that the new address displacement will fit 4 bytes. if (MI.getOperand(MemOpNo + X86::AddrDisp).isImm() && !isInt<32>(MI.getOperand(MemOpNo + X86::AddrDisp).getImm() +