diff options
| author | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-07-12 08:37:17 +0000 |
|---|---|---|
| committer | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-07-12 08:37:17 +0000 |
| commit | 3f0edc29036dfbd780c42fbe074048b782dd47c9 (patch) | |
| tree | 4fb1d821e7bb55ed139603d9608155076d9f05c4 /llvm/lib | |
| parent | 23773b34c624ef3baff101e82a381c7aa255a85d (diff) | |
| download | bcm5719-llvm-3f0edc29036dfbd780c42fbe074048b782dd47c9.tar.gz bcm5719-llvm-3f0edc29036dfbd780c42fbe074048b782dd47c9.zip | |
[SystemZ] Improve spilling of LGDR and LDGR
If the source of these instructions is spilled we should load the destination.
If the destination is spilled we should store the source.
llvm-svn: 186147
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp index cfd270ae434..bbac73fcaff 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -368,6 +368,28 @@ SystemZInstrInfo::foldMemoryOperandImpl(MachineFunction &MF, .getRegClass(MI->getOperand(OpNum).getReg())->getSize() && "Invalid size combination"); + unsigned Opcode = MI->getOpcode(); + if (Opcode == SystemZ::LGDR || Opcode == SystemZ::LDGR) { + bool Op0IsGPR = (Opcode == SystemZ::LGDR); + bool Op1IsGPR = (Opcode == SystemZ::LDGR); + // If we're spilling the destination of an LDGR or LGDR, store the + // source register instead. + if (OpNum == 0) { + unsigned StoreOpcode = Op1IsGPR ? SystemZ::STG : SystemZ::STD; + return BuildMI(MF, MI->getDebugLoc(), get(StoreOpcode)) + .addOperand(MI->getOperand(1)).addFrameIndex(FrameIndex) + .addImm(0).addReg(0); + } + // If we're spilling the source of an LDGR or LGDR, load the + // destination register instead. + if (OpNum == 1) { + unsigned LoadOpcode = Op0IsGPR ? SystemZ::LG : SystemZ::LD; + unsigned Dest = MI->getOperand(0).getReg(); + return BuildMI(MF, MI->getDebugLoc(), get(LoadOpcode), Dest) + .addFrameIndex(FrameIndex).addImm(0).addReg(0); + } + } + // Look for cases where the source of a simple store or the destination // of a simple load is being spilled. Try to use MVC instead. // @@ -399,7 +421,7 @@ SystemZInstrInfo::foldMemoryOperandImpl(MachineFunction &MF, // If the spilled operand is the final one, try to change <INSN>R // into <INSN>. - int MemOpcode = SystemZ::getMemOpcode(MI->getOpcode()); + int MemOpcode = SystemZ::getMemOpcode(Opcode); if (MemOpcode >= 0) { unsigned NumOps = MI->getNumExplicitOperands(); if (OpNum == NumOps - 1) { |

