summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/R600/SIShrinkInstructions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/R600/SIShrinkInstructions.cpp')
-rw-r--r--llvm/lib/Target/R600/SIShrinkInstructions.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Target/R600/SIShrinkInstructions.cpp b/llvm/lib/Target/R600/SIShrinkInstructions.cpp
index 0b9e7ca9666..45e83f54e7c 100644
--- a/llvm/lib/Target/R600/SIShrinkInstructions.cpp
+++ b/llvm/lib/Target/R600/SIShrinkInstructions.cpp
@@ -189,6 +189,19 @@ bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
Next = std::next(I);
MachineInstr &MI = *I;
+ // Try to use S_MOVK_I32, which will save 4 bytes for small immediates.
+ if (MI.getOpcode() == AMDGPU::S_MOV_B32) {
+ const MachineOperand &Src = MI.getOperand(1);
+
+ // TODO: Handle FPImm?
+ if (Src.isImm()) {
+ if (isInt<16>(Src.getImm()) && !TII->isInlineConstant(Src)) {
+ MI.setDesc(TII->get(AMDGPU::S_MOVK_I32));
+ continue;
+ }
+ }
+ }
+
if (!TII->hasVALU32BitEncoding(MI.getOpcode()))
continue;
OpenPOWER on IntegriCloud