diff options
| author | Kyle Butt <kyle+llvm@iteratee.net> | 2017-09-09 00:37:56 +0000 |
|---|---|---|
| committer | Kyle Butt <kyle+llvm@iteratee.net> | 2017-09-09 00:37:56 +0000 |
| commit | 8c0314c3ed50b915113d0f4f64de0ead2286188d (patch) | |
| tree | 885b613abb2d501408f0478c8670d47398b2a9d0 /llvm/lib/Target/PowerPC | |
| parent | 285c93666bb624997f67497059ab352de81e5b47 (diff) | |
| download | bcm5719-llvm-8c0314c3ed50b915113d0f4f64de0ead2286188d.tar.gz bcm5719-llvm-8c0314c3ed50b915113d0f4f64de0ead2286188d.zip | |
PPC: Don't select lxv/stxv for insufficiently aligned stack slots.
The lxv/stxv instructions require an offset that is 0 % 16. Previously we were
selecting lxv/stxv for loads and stores to the stack where the offset from the
slot was a multiple of 16, but the stack slot was not 16 or more byte aligned.
When the frame gets lowered these transform to r(1|31) + slot + offset.
If slot is not aligned, slot + offset may not be 0 % 16.
Now we require 16 byte or more alignment for select lxv/stxv to stack slots.
Includes a testcase that shows both sufficiently and insufficiently aligned
stack slots.
llvm-svn: 312843
Diffstat (limited to 'llvm/lib/Target/PowerPC')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 2eba6c7fa99..c9a5faa86f6 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -3055,8 +3055,18 @@ bool PPCDAGToDAGISel::isOffsetMultipleOf(SDNode *N, unsigned Val) const { AddrOp = STN->getOperand(2); short Imm = 0; - if (AddrOp.getOpcode() == ISD::ADD) + if (AddrOp.getOpcode() == ISD::ADD) { + // If op0 is a frame index that is under aligned, we can't do it either, + // because it is translated to r31 or r1 + slot + offset. We won't know the + // slot number until the stack frame is finalized. + if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(AddrOp.getOperand(0))) { + const MachineFrameInfo &MFI = CurDAG->getMachineFunction().getFrameInfo(); + unsigned SlotAlign = MFI.getObjectAlignment(FI->getIndex()); + if ((SlotAlign % Val) != 0) + return false; + } return isIntS16Immediate(AddrOp.getOperand(1), Imm) && !(Imm % Val); + } // If the address comes from the outside, the offset will be zero. return AddrOp.getOpcode() == ISD::CopyFromReg; |

