[llvm] r195033 - R600/SI: Fix extra defs of VCC / SCC.

Matt Arsenault Matthew.Arsenault at amd.com
Mon Nov 18 12:09:21 PST 2013


Author: arsenm
Date: Mon Nov 18 14:09:21 2013
New Revision: 195033

URL: http://llvm.org/viewvc/llvm-project?rev=195033&view=rev
Log:
R600/SI: Fix extra defs of VCC / SCC.

When replacing scalar operations with vector,
the wrong implicit output register was used.

Modified:
    llvm/trunk/lib/Target/R600/SIInstrInfo.cpp

Modified: llvm/trunk/lib/Target/R600/SIInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIInstrInfo.cpp?rev=195033&r1=195032&r2=195033&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/R600/SIInstrInfo.cpp Mon Nov 18 14:09:21 2013
@@ -466,6 +466,8 @@ void SIInstrInfo::legalizeOperands(Machi
         if (!RI.isSGPRClass(MRI.getRegClass(MO.getReg())))
           continue; // VGPRs are legal
 
+        assert(MO.getReg() != AMDGPU::SCC && "SCC operand to VOP3 instruction");
+
         if (SGPRReg == AMDGPU::NoRegister || SGPRReg == MO.getReg()) {
           SGPRReg = MO.getReg();
           // We can use one SGPR in each VOP3 instruction.
@@ -543,18 +545,27 @@ void SIInstrInfo::moveToVALU(MachineInst
     const MCInstrDesc &NewDesc = get(NewOpcode);
     Inst->setDesc(NewDesc);
 
+    // Remove any references to SCC. Vector instructions can't read from it, and
+    // We're just about to add the implicit use / defs of VCC, and we don't want
+    // both.
+    for (unsigned i = Inst->getNumOperands() - 1; i > 0; --i) {
+      MachineOperand &Op = Inst->getOperand(i);
+      if (Op.isReg() && Op.getReg() == AMDGPU::SCC)
+        Inst->RemoveOperand(i);
+    }
+
     // Add the implict and explicit register definitions.
     if (NewDesc.ImplicitUses) {
       for (unsigned i = 0; NewDesc.ImplicitUses[i]; ++i) {
-        Inst->addOperand(MachineOperand::CreateReg(NewDesc.ImplicitUses[i],
-                                                   false, true));
+        unsigned Reg = NewDesc.ImplicitUses[i];
+        Inst->addOperand(MachineOperand::CreateReg(Reg, false, true));
       }
     }
 
     if (NewDesc.ImplicitDefs) {
       for (unsigned i = 0; NewDesc.ImplicitDefs[i]; ++i) {
-        Inst->addOperand(MachineOperand::CreateReg(NewDesc.ImplicitDefs[i],
-                                                   true, true));
+        unsigned Reg = NewDesc.ImplicitDefs[i];
+        Inst->addOperand(MachineOperand::CreateReg(Reg, true, true));
       }
     }
 





More information about the llvm-commits mailing list