diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2014-08-01 00:32:28 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2014-08-01 00:32:28 +0000 |
commit | 86d12ebdbd33c0d04f4ecd74003a51abb55d488f (patch) | |
tree | 42fbe6faf19617c410a8832f9b0f835ab20e36ef /llvm/lib | |
parent | 05fb383d2b867b8cfcbcbd0cd28cd1d67bcae998 (diff) | |
download | bcm5719-llvm-86d12ebdbd33c0d04f4ecd74003a51abb55d488f.tar.gz bcm5719-llvm-86d12ebdbd33c0d04f4ecd74003a51abb55d488f.zip |
R600/SI: Fix incorrect commute operation in shrink instructions pass
We were commuting the instruction by still shrinking it using the
original opcode.
NOTE: This is a candidate for the 3.5 branch.
llvm-svn: 214463
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/R600/SIInstrInfo.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Target/R600/SIInstrInfo.h | 4 | ||||
-rw-r--r-- | llvm/lib/Target/R600/SIShrinkInstructions.cpp | 11 |
3 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/Target/R600/SIInstrInfo.cpp b/llvm/lib/Target/R600/SIInstrInfo.cpp index 0249ad07208..fc395ee4919 100644 --- a/llvm/lib/Target/R600/SIInstrInfo.cpp +++ b/llvm/lib/Target/R600/SIInstrInfo.cpp @@ -668,6 +668,10 @@ bool SIInstrInfo::isImmOperandLegal(const MachineInstr *MI, unsigned OpNo, return RI.regClassCanUseImmediate(OpInfo.RegClass); } +bool SIInstrInfo::hasVALU32BitEncoding(unsigned Opcode) const { + return AMDGPU::getVOPe32(Opcode) != -1; +} + bool SIInstrInfo::verifyInstruction(const MachineInstr *MI, StringRef &ErrInfo) const { uint16_t Opcode = MI->getOpcode(); diff --git a/llvm/lib/Target/R600/SIInstrInfo.h b/llvm/lib/Target/R600/SIInstrInfo.h index c53298add02..48d6ca5fcf3 100644 --- a/llvm/lib/Target/R600/SIInstrInfo.h +++ b/llvm/lib/Target/R600/SIInstrInfo.h @@ -115,6 +115,10 @@ public: bool isImmOperandLegal(const MachineInstr *MI, unsigned OpNo, const MachineOperand &MO) const; + /// \brief Return true if this 64-bit VALU instruction has a 32-bit encoding. + /// This function will return false if you pass it a 32-bit instruction. + bool hasVALU32BitEncoding(unsigned Opcode) const; + bool verifyInstruction(const MachineInstr *MI, StringRef &ErrInfo) const override; diff --git a/llvm/lib/Target/R600/SIShrinkInstructions.cpp b/llvm/lib/Target/R600/SIShrinkInstructions.cpp index 362a5c1e4e0..745c4b65644 100644 --- a/llvm/lib/Target/R600/SIShrinkInstructions.cpp +++ b/llvm/lib/Target/R600/SIShrinkInstructions.cpp @@ -125,9 +125,7 @@ bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) { Next = std::next(I); MachineInstr &MI = *I; - int Op32 = AMDGPU::getVOPe32(MI.getOpcode()); - - if (Op32 == -1) + if (!TII->hasVALU32BitEncoding(MI.getOpcode())) continue; if (!canShrink(MI, TII, TRI, MRI)) { @@ -138,6 +136,13 @@ bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) { continue; } + int Op32 = AMDGPU::getVOPe32(MI.getOpcode()); + + // Op32 could be -1 here if we started with an instruction that had a + // a 32-bit encoding and then commuted it to an instruction that did not. + if (Op32 == -1) + continue; + if (TII->isVOPC(Op32)) { unsigned DstReg = MI.getOperand(0).getReg(); if (TargetRegisterInfo::isVirtualRegister(DstReg)) { |