Index: lib/Target/R600/AMDGPUAsmPrinter.cpp =================================================================== --- lib/Target/R600/AMDGPUAsmPrinter.cpp +++ lib/Target/R600/AMDGPUAsmPrinter.cpp @@ -314,7 +314,7 @@ llvm_unreachable("Unknown register class"); } unsigned hwReg = RI->getEncodingValue(reg) & 0xff; - unsigned maxUsed = hwReg + width - 1; + unsigned maxUsed = hwReg + width; if (isSGPR) { MaxSGPR = maxUsed > MaxSGPR ? maxUsed : MaxSGPR; } else { Index: test/CodeGen/R600/no_vgpr_used.ll =================================================================== --- /dev/null +++ test/CodeGen/R600/no_vgpr_used.ll @@ -0,0 +1,8 @@ +; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s + +; SI-LABEL: @no_vgpr_used +; SI: NumVgprs: 1 +define void @no_vgpr_used(i32 addrspace(1)* %out, i32 %x) nounwind { + store i32 %x, i32 addrspace(1)* %out, align 4 + ret void +}