diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2015-09-09 15:43:26 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-09-09 15:43:26 +0000 |
commit | 9a197676b13333be2d4628a413e863ce44ab6697 (patch) | |
tree | e0cec7b57d87246eac7d90b5e216b5aae8997a6e /llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | |
parent | a3e27edb5d2cc6c4c5ec85ce8de19b3177c07bd0 (diff) | |
download | llvm-9a197676b13333be2d4628a413e863ce44ab6697.zip llvm-9a197676b13333be2d4628a413e863ce44ab6697.tar.gz llvm-9a197676b13333be2d4628a413e863ce44ab6697.tar.bz2 |
AMDGPU/SI: Fold operands through REG_SEQUENCE instructions
Summary:
This helps mostly when we use add instructions for address calculations
that contain immediates.
Reviewers: arsenm
Subscribers: arsenm, llvm-commits
Differential Revision: http://reviews.llvm.org/D12256
llvm-svn: 247157
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIFoldOperands.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp index eff9c07..fe11385 100644 --- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp +++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp @@ -245,6 +245,27 @@ static void foldOperand(MachineOperand &OpToFold, MachineInstr *UseMI, } } + // Special case for REG_SEQUENCE: We can't fold literals into + // REG_SEQUENCE instructions, so we have to fold them into the + // uses of REG_SEQUENCE. + if (UseMI->getOpcode() == AMDGPU::REG_SEQUENCE) { + unsigned RegSeqDstReg = UseMI->getOperand(0).getReg(); + unsigned RegSeqDstSubReg = UseMI->getOperand(UseOpIdx + 1).getImm(); + + for (MachineRegisterInfo::use_iterator + RSUse = MRI.use_begin(RegSeqDstReg), + RSE = MRI.use_end(); RSUse != RSE; ++RSUse) { + + MachineInstr *RSUseMI = RSUse->getParent(); + if (RSUse->getSubReg() != RegSeqDstSubReg) + continue; + + foldOperand(OpToFold, RSUseMI, RSUse.getOperandNo(), FoldList, + TII, TRI, MRI); + } + return; + } + const MCInstrDesc &UseDesc = UseMI->getDesc(); // Don't fold into target independent nodes. Target independent opcodes |