Skip to content

Commit d17bcf2

Browse files
committed
[AMDGPU] Add handling of 160 bit registers in analyzeResourceUsage
This was omitted. Also SReg_96Reg missed IsSGPR assignment. Differential Revision: https://reviews.llvm.org/D69919
1 parent e74e61f commit d17bcf2

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ AMDGPUAsmPrinter::SIFunctionResourceInfo AMDGPUAsmPrinter::analyzeResourceUsage(
793793
IsSGPR = false;
794794
Width = 3;
795795
} else if (AMDGPU::SReg_96RegClass.contains(Reg)) {
796+
IsSGPR = true;
796797
Width = 3;
797798
} else if (AMDGPU::SReg_128RegClass.contains(Reg)) {
798799
assert(!AMDGPU::TTMP_128RegClass.contains(Reg) &&
@@ -806,6 +807,12 @@ AMDGPUAsmPrinter::SIFunctionResourceInfo AMDGPUAsmPrinter::analyzeResourceUsage(
806807
IsSGPR = false;
807808
IsAGPR = true;
808809
Width = 4;
810+
} else if (AMDGPU::VReg_160RegClass.contains(Reg)) {
811+
IsSGPR = false;
812+
Width = 5;
813+
} else if (AMDGPU::SReg_160RegClass.contains(Reg)) {
814+
IsSGPR = true;
815+
Width = 5;
809816
} else if (AMDGPU::SReg_256RegClass.contains(Reg)) {
810817
assert(!AMDGPU::TTMP_256RegClass.contains(Reg) &&
811818
"trap handler registers should not be used");

llvm/test/CodeGen/AMDGPU/call-graph-register-usage.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,34 @@ entry:
238238
ret void
239239
}
240240

241+
; Make sure there's no assert when a sgpr160 is used.
242+
; GCN-LABEL: {{^}}count_use_sgpr160_external_call
243+
; GCN: ; sgpr160 s[{{[0-9]+}}:{{[0-9]+}}]
244+
; CI: NumSgprs: 48
245+
; VI-NOBUG: NumSgprs: 48
246+
; VI-BUG: NumSgprs: 96
247+
; GCN: NumVgprs: 24
248+
define amdgpu_kernel void @count_use_sgpr160_external_call() {
249+
entry:
250+
tail call void asm sideeffect "; sgpr160 $0", "s"(<5 x i32> <i32 10, i32 11, i32 12, i32 13, i32 14>) #1
251+
call void @external()
252+
ret void
253+
}
254+
255+
; Make sure there's no assert when a vgpr160 is used.
256+
; GCN-LABEL: {{^}}count_use_vgpr160_external_call
257+
; GCN: ; vgpr160 v[{{[0-9]+}}:{{[0-9]+}}]
258+
; CI: NumSgprs: 48
259+
; VI-NOBUG: NumSgprs: 48
260+
; VI-BUG: NumSgprs: 96
261+
; GCN: NumVgprs: 24
262+
define amdgpu_kernel void @count_use_vgpr160_external_call() {
263+
entry:
264+
tail call void asm sideeffect "; vgpr160 $0", "v"(<5 x i32> <i32 10, i32 11, i32 12, i32 13, i32 14>) #1
265+
call void @external()
266+
ret void
267+
}
268+
241269
attributes #0 = { nounwind noinline norecurse }
242270
attributes #1 = { nounwind noinline norecurse }
243271
attributes #2 = { nounwind noinline }

0 commit comments

Comments
 (0)