@@ -57,6 +57,24 @@ struct GCNRegPressure {
5757 return std::max (Value[VGPR] + Value[AVGPR], Value[AGPR]);
5858 }
5959
60+ inline static unsigned getAVGPRsAsVGPRsNum (unsigned NumArchVGPRs,
61+ unsigned NumAVGPRs,
62+ unsigned AddressableArchVGPR) {
63+
64+ return NumArchVGPRs < AddressableArchVGPR
65+ ? std::min ((AddressableArchVGPR - NumArchVGPRs), NumAVGPRs)
66+ : 0 ;
67+ }
68+
69+ inline static unsigned getAVGPRsAsAGPRsNum (unsigned NumArchVGPRs,
70+ unsigned NumAGPRs,
71+ unsigned NumAVGPRs,
72+ unsigned AddressableArchVGPR) {
73+ unsigned AVGPRsAsVGPRs =
74+ getAVGPRsAsVGPRsNum (NumArchVGPRs, NumAVGPRs, AddressableArchVGPR);
75+ return NumAVGPRs > AVGPRsAsVGPRs ? NumAVGPRs - AVGPRsAsVGPRs : 0 ;
76+ }
77+
6078 // / Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
6179 // / \p NumAGPRs AGPRS, and \p NumAVGPRs AVGPRs for a target with a unified
6280 // / VGPR file.
@@ -68,11 +86,10 @@ struct GCNRegPressure {
6886 // Until we hit the VGPRThreshold, we will assign AV as VGPR. After that
6987 // point, we will assign as AGPR.
7088 unsigned AVGPRsAsVGPRs =
71- NumArchVGPRs < AddressableArchVGPR
72- ? std::min ((AddressableArchVGPR - NumArchVGPRs), NumAVGPRs)
73- : 0 ;
74- unsigned AVGPRsAsAGPRs =
75- NumAVGPRs > AVGPRsAsVGPRs ? NumAVGPRs - AVGPRsAsVGPRs : 0 ;
89+ getAVGPRsAsVGPRsNum (NumArchVGPRs, NumAVGPRs, AddressableArchVGPR);
90+ unsigned AVGPRsAsAGPRs = getAVGPRsAsAGPRsNum (
91+ NumArchVGPRs, NumAGPRs, NumAVGPRs, AddressableArchVGPR);
92+ NumAVGPRs > AVGPRsAsVGPRs ? NumAVGPRs - AVGPRsAsVGPRs : 0 ;
7693 return alignTo (NumArchVGPRs + AVGPRsAsVGPRs,
7794 AMDGPU::IsaInfo::getArchVGPRAllocGranule ()) +
7895 NumAGPRs + AVGPRsAsAGPRs;
@@ -96,13 +113,11 @@ struct GCNRegPressure {
96113
97114 unsigned getVGPRTuplesWeight (unsigned AddressableArchVGPR) const {
98115 unsigned AVGPRsAsVGPRs =
99- Value[TOTAL_KINDS + VGPR] < AddressableArchVGPR
100- ? std::min (AddressableArchVGPR - Value[TOTAL_KINDS + VGPR],
101- Value[TOTAL_KINDS + AVGPR])
102- : 0 ;
103- unsigned AVGPRsAsAGPRs = Value[TOTAL_KINDS + AVGPR] > AVGPRsAsVGPRs
104- ? Value[TOTAL_KINDS + AVGPR] - AVGPRsAsVGPRs
105- : 0 ;
116+ getAVGPRsAsVGPRsNum (Value[TOTAL_KINDS + VGPR],
117+ Value[TOTAL_KINDS + AVGPR], AddressableArchVGPR);
118+ unsigned AVGPRsAsAGPRs = getAVGPRsAsAGPRsNum (
119+ Value[TOTAL_KINDS + VGPR], Value[TOTAL_KINDS + AGPR],
120+ Value[TOTAL_KINDS + AVGPR], AddressableArchVGPR);
106121
107122 return std::max (Value[TOTAL_KINDS + VGPR] + AVGPRsAsVGPRs,
108123 Value[TOTAL_KINDS + AGPR] + AVGPRsAsAGPRs);
0 commit comments