[llvm-commits] [llvm] r53784 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
Anton Korobeynikov
asl at math.spbu.ru
Fri Jul 18 23:30:51 PDT 2008
Author: asl
Date: Sat Jul 19 01:30:51 2008
New Revision: 53784
URL: http://llvm.org/viewvc/llvm-project?rev=53784&view=rev
Log:
Use aligned stack spills, where possible. This fixes PR2549.
Modified:
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=53784&r1=53783&r2=53784&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Sat Jul 19 01:30:51 2008
@@ -1697,7 +1697,7 @@
}
static unsigned getStoreRegOpcode(const TargetRegisterClass *RC,
- unsigned StackAlign) {
+ bool isStackAligned) {
unsigned Opc = 0;
if (RC == &X86::GR64RegClass) {
Opc = X86::MOV64mr;
@@ -1722,9 +1722,8 @@
} else if (RC == &X86::FR64RegClass) {
Opc = X86::MOVSDmr;
} else if (RC == &X86::VR128RegClass) {
- // FIXME: Use movaps once we are capable of selectively
- // aligning functions that spill SSE registers on 16-byte boundaries.
- Opc = StackAlign >= 16 ? X86::MOVAPSmr : X86::MOVUPSmr;
+ // If stack is realigned we can use aligned stores.
+ Opc = isStackAligned ? X86::MOVAPSmr : X86::MOVUPSmr;
} else if (RC == &X86::VR64RegClass) {
Opc = X86::MMX_MOVQ64mr;
} else {
@@ -1739,7 +1738,8 @@
MachineBasicBlock::iterator MI,
unsigned SrcReg, bool isKill, int FrameIdx,
const TargetRegisterClass *RC) const {
- unsigned Opc = getStoreRegOpcode(RC, RI.getStackAlignment());
+ const MachineFunction &MF = *MBB.getParent();
+ unsigned Opc = getStoreRegOpcode(RC, RI.needsStackRealignment(MF));
addFrameReference(BuildMI(MBB, MI, get(Opc)), FrameIdx)
.addReg(SrcReg, false, false, isKill);
}
@@ -1749,7 +1749,7 @@
SmallVectorImpl<MachineOperand> &Addr,
const TargetRegisterClass *RC,
SmallVectorImpl<MachineInstr*> &NewMIs) const {
- unsigned Opc = getStoreRegOpcode(RC, RI.getStackAlignment());
+ unsigned Opc = getStoreRegOpcode(RC, RI.needsStackRealignment(MF));
MachineInstrBuilder MIB = BuildMI(MF, get(Opc));
for (unsigned i = 0, e = Addr.size(); i != e; ++i)
MIB = X86InstrAddOperand(MIB, Addr[i]);
@@ -1758,7 +1758,7 @@
}
static unsigned getLoadRegOpcode(const TargetRegisterClass *RC,
- unsigned StackAlign) {
+ bool isStackAligned) {
unsigned Opc = 0;
if (RC == &X86::GR64RegClass) {
Opc = X86::MOV64rm;
@@ -1783,9 +1783,8 @@
} else if (RC == &X86::FR64RegClass) {
Opc = X86::MOVSDrm;
} else if (RC == &X86::VR128RegClass) {
- // FIXME: Use movaps once we are capable of selectively
- // aligning functions that spill SSE registers on 16-byte boundaries.
- Opc = StackAlign >= 16 ? X86::MOVAPSrm : X86::MOVUPSrm;
+ // If stack is realigned we can use aligned loads.
+ Opc = isStackAligned ? X86::MOVAPSrm : X86::MOVUPSrm;
} else if (RC == &X86::VR64RegClass) {
Opc = X86::MMX_MOVQ64rm;
} else {
@@ -1797,10 +1796,11 @@
}
void X86InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator MI,
- unsigned DestReg, int FrameIdx,
- const TargetRegisterClass *RC) const{
- unsigned Opc = getLoadRegOpcode(RC, RI.getStackAlignment());
+ MachineBasicBlock::iterator MI,
+ unsigned DestReg, int FrameIdx,
+ const TargetRegisterClass *RC) const{
+ const MachineFunction &MF = *MBB.getParent();
+ unsigned Opc = getLoadRegOpcode(RC, RI.needsStackRealignment(MF));
addFrameReference(BuildMI(MBB, MI, get(Opc), DestReg), FrameIdx);
}
@@ -1808,7 +1808,7 @@
SmallVectorImpl<MachineOperand> &Addr,
const TargetRegisterClass *RC,
SmallVectorImpl<MachineInstr*> &NewMIs) const {
- unsigned Opc = getLoadRegOpcode(RC, RI.getStackAlignment());
+ unsigned Opc = getLoadRegOpcode(RC, RI.needsStackRealignment(MF));
MachineInstrBuilder MIB = BuildMI(MF, get(Opc), DestReg);
for (unsigned i = 0, e = Addr.size(); i != e; ++i)
MIB = X86InstrAddOperand(MIB, Addr[i]);
@@ -2272,10 +2272,12 @@
// Emit the load instruction.
SDNode *Load = 0;
+ const MachineFunction &MF = DAG.getMachineFunction();
if (FoldedLoad) {
MVT VT = *RC->vt_begin();
- Load = DAG.getTargetNode(getLoadRegOpcode(RC, RI.getStackAlignment()), VT,
- MVT::Other, &AddrOps[0], AddrOps.size());
+ Load = DAG.getTargetNode(getLoadRegOpcode(RC, RI.needsStackRealignment(MF)),
+ VT, MVT::Other,
+ &AddrOps[0], AddrOps.size());
NewNodes.push_back(Load);
}
@@ -2304,8 +2306,10 @@
AddrOps.pop_back();
AddrOps.push_back(SDOperand(NewNode, 0));
AddrOps.push_back(Chain);
- SDNode *Store = DAG.getTargetNode(getStoreRegOpcode(DstRC, RI.getStackAlignment()),
- MVT::Other, &AddrOps[0], AddrOps.size());
+ SDNode *Store =
+ DAG.getTargetNode(getStoreRegOpcode(DstRC,
+ RI.needsStackRealignment(MF)),
+ MVT::Other, &AddrOps[0], AddrOps.size());
NewNodes.push_back(Store);
}
More information about the llvm-commits
mailing list