[llvm] r229227 - R600/SI: Fix phys reg copies in SIFoldOperands

Matt Arsenault Matthew.Arsenault at amd.com
Fri Feb 13 18:55:57 PST 2015


Author: arsenm
Date: Fri Feb 13 20:55:57 2015
New Revision: 229227

URL: http://llvm.org/viewvc/llvm-project?rev=229227&view=rev
Log:
R600/SI: Fix phys reg copies in SIFoldOperands

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

Modified: llvm/trunk/lib/Target/R600/SIFoldOperands.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIFoldOperands.cpp?rev=229227&r1=229226&r2=229227&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIFoldOperands.cpp (original)
+++ llvm/trunk/lib/Target/R600/SIFoldOperands.cpp Fri Feb 13 20:55:57 2015
@@ -210,7 +210,12 @@ bool SIFoldOperands::runOnMachineFunctio
         APInt Imm;
 
         if (FoldingImm) {
-          const TargetRegisterClass *UseRC = MRI.getRegClass(UseOp.getReg());
+          unsigned UseReg = UseOp.getReg();
+          const TargetRegisterClass *UseRC
+            = TargetRegisterInfo::isVirtualRegister(UseReg) ?
+            MRI.getRegClass(UseReg) :
+            TRI.getRegClass(UseReg);
+
           Imm = APInt(64, OpToFold.getImm());
 
           // Split 64-bit constants into 32-bits for folding.
@@ -229,8 +234,13 @@ bool SIFoldOperands::runOnMachineFunctio
           // In order to fold immediates into copies, we need to change the
           // copy to a MOV.
           if (UseMI->getOpcode() == AMDGPU::COPY) {
-            unsigned MovOp = TII->getMovOpcode(
-                MRI.getRegClass(UseMI->getOperand(0).getReg()));
+            unsigned DestReg = UseMI->getOperand(0).getReg();
+            const TargetRegisterClass *DestRC
+              = TargetRegisterInfo::isVirtualRegister(DestReg) ?
+              MRI.getRegClass(DestReg) :
+              TRI.getRegClass(DestReg);
+
+            unsigned MovOp = TII->getMovOpcode(DestRC);
             if (MovOp == AMDGPU::COPY)
               continue;
 





More information about the llvm-commits mailing list