AMDGPU/SI: Use v_readfirstlane_b32 when restoring SGPRs spilled to scratch
authorTom Stellard <thomas.stellard@amd.com>
Mon, 2 May 2016 20:11:44 +0000 (20:11 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 2 May 2016 20:11:44 +0000 (20:11 +0000)
We were using v_readlane_b32 with the lane set to zero, but this won't
work if thread 0 is not active.

Differential Revision: http://reviews.llvm.org/D19745

llvm-svn: 268295

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/test/CodeGen/AMDGPU/si-spill-sgpr-stack.ll

index 9012b31..ac569d9 100644 (file)
@@ -589,9 +589,8 @@ void SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
                   .addImm(i * 4)                          // offset
                   .addMemOperand(MMO);
           BuildMI(*MBB, MI, DL,
-                  TII->getMCOpcodeFromPseudo(AMDGPU::V_READLANE_B32), SubReg)
+                  TII->get(AMDGPU::V_READFIRSTLANE_B32), SubReg)
                   .addReg(TmpReg, RegState::Kill)
-                  .addImm(0)
                   .addReg(MI->getOperand(0).getReg(), RegState::ImplicitDefine);
         }
       }
index 0731a4e..5171406 100644 (file)
@@ -5,7 +5,7 @@
 ; Make sure we are handling hazards correctly.
 ; CHECK: buffer_load_dword [[VHI:v[0-9]+]], off, s[{{[0-9]+:[0-9]+}}], s{{[0-9]+}} offset:12
 ; CHECK-NEXT: s_waitcnt vmcnt(0)
-; CHECK-NEXT: v_readlane_b32 s[[HI:[0-9]+]], [[VHI]]
+; CHECK-NEXT: v_readfirstlane_b32 s[[HI:[0-9]+]], [[VHI]]
 ; CHECK-NEXT: s_nop 4
 ; CHECK-NEXT: buffer_store_dword v0, off, s[0:[[HI]]{{\]}}, 0
 ; CHECK: s_endpgm