From 86ffcddf42ef7dc2b90dd9b7a4d1aa4d9cb05ebb Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 11 Sep 2014 22:51:37 +0000 Subject: [PATCH] R600/SI: Fix off by 1 error in used register count The register numbers start at 0, so if only 1 register was used, this was reported as 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217636 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/R600/AMDGPUAsmPrinter.cpp | 6 ++++-- test/CodeGen/R600/register-count-comments.ll | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Target/R600/AMDGPUAsmPrinter.cpp b/lib/Target/R600/AMDGPUAsmPrinter.cpp index 7f0cbe575d0..845a46b1e63 100644 --- a/lib/Target/R600/AMDGPUAsmPrinter.cpp +++ b/lib/Target/R600/AMDGPUAsmPrinter.cpp @@ -322,8 +322,10 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo, if (VCCUsed) MaxSGPR += 2; - ProgInfo.NumVGPR = MaxVGPR; - ProgInfo.NumSGPR = MaxSGPR; + // We found the maximum register index. They start at 0, so add one to get the + // number of registers. + ProgInfo.NumVGPR = MaxVGPR + 1; + ProgInfo.NumSGPR = MaxSGPR + 1; // Set the value to initialize FP_ROUND and FP_DENORM parts of the mode // register. diff --git a/test/CodeGen/R600/register-count-comments.ll b/test/CodeGen/R600/register-count-comments.ll index 329077cde57..6179013f5fc 100644 --- a/test/CodeGen/R600/register-count-comments.ll +++ b/test/CodeGen/R600/register-count-comments.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI %s +; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs -asm-verbose < %s | FileCheck -check-prefix=SI %s declare i32 @llvm.SI.tid() nounwind readnone @@ -18,3 +18,10 @@ define void @foo(i32 addrspace(1)* noalias %out, i32 addrspace(1)* %abase, i32 a store i32 %result, i32 addrspace(1)* %outptr, align 4 ret void } + +; SI-LABEL: @one_vgpr_used +; SI: NumVgprs: 1 +define void @one_vgpr_used(i32 addrspace(1)* %out, i32 %x) nounwind { + store i32 %x, i32 addrspace(1)* %out, align 4 + ret void +} -- 2.34.1