[llvm] f34bb06 - [X86] When expanding LCMPXCHG16B_NO_RBX in EmitInstrWithCustomInserter, directly copy address operands instead of going through X86AddressMode.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 11:56:32 PDT 2020
Author: Craig Topper
Date: 2020-10-09T11:55:24-07:00
New Revision: f34bb06935aa3bab353d70d515b767fdd2f5625c
URL: https://github.com/llvm/llvm-project/commit/f34bb06935aa3bab353d70d515b767fdd2f5625c
DIFF: https://github.com/llvm/llvm-project/commit/f34bb06935aa3bab353d70d515b767fdd2f5625c.diff
LOG: [X86] When expanding LCMPXCHG16B_NO_RBX in EmitInstrWithCustomInserter, directly copy address operands instead of going through X86AddressMode.
I suspect getAddressFromInstr and addFullAddress are not handling
all addresses cases properly based on a report from MaskRay.
So just copy the operands directly. This should be more efficient
anyway.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 9e17cab10643..5d4dfaab4503 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -33765,7 +33765,6 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
case X86::LCMPXCHG16B_NO_RBX: {
const X86RegisterInfo *TRI = Subtarget.getRegisterInfo();
Register BasePtr = TRI->getBaseRegister();
- X86AddressMode AM = getAddressFromInstr(&MI, 0);
if (TRI->hasBasePointer(*MF) &&
(BasePtr == X86::RBX || BasePtr == X86::EBX)) {
if (!BB->isLiveIn(BasePtr))
@@ -33776,15 +33775,20 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
BuildMI(*BB, MI, DL, TII->get(TargetOpcode::COPY), SaveRBX)
.addReg(X86::RBX);
Register Dst = MF->getRegInfo().createVirtualRegister(&X86::GR64RegClass);
- addFullAddress(
- BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B_SAVE_RBX), Dst), AM)
- .add(MI.getOperand(X86::AddrNumOperands))
- .addReg(SaveRBX);
+ MachineInstrBuilder MIB =
+ BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B_SAVE_RBX), Dst);
+ for (unsigned Idx = 0; Idx < X86::AddrNumOperands; ++Idx)
+ MIB.add(MI.getOperand(Idx));
+ MIB.add(MI.getOperand(X86::AddrNumOperands));
+ MIB.addReg(SaveRBX);
} else {
// Simple case, just copy the virtual register to RBX.
BuildMI(*BB, MI, DL, TII->get(TargetOpcode::COPY), X86::RBX)
.add(MI.getOperand(X86::AddrNumOperands));
- addFullAddress(BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B)), AM);
+ MachineInstrBuilder MIB =
+ BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B));
+ for (unsigned Idx = 0; Idx < X86::AddrNumOperands; ++Idx)
+ MIB.add(MI.getOperand(Idx));
}
MI.eraseFromParent();
return BB;
More information about the llvm-commits
mailing list