@@ -57,6 +57,24 @@ struct GCNRegPressure {
57
57
return std::max (Value[VGPR] + Value[AVGPR], Value[AGPR]);
58
58
}
59
59
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
+
60
78
// / Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
61
79
// / \p NumAGPRs AGPRS, and \p NumAVGPRs AVGPRs for a target with a unified
62
80
// / VGPR file.
@@ -68,11 +86,10 @@ struct GCNRegPressure {
68
86
// Until we hit the VGPRThreshold, we will assign AV as VGPR. After that
69
87
// point, we will assign as AGPR.
70
88
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 ;
76
93
return alignTo (NumArchVGPRs + AVGPRsAsVGPRs,
77
94
AMDGPU::IsaInfo::getArchVGPRAllocGranule ()) +
78
95
NumAGPRs + AVGPRsAsAGPRs;
@@ -96,13 +113,11 @@ struct GCNRegPressure {
96
113
97
114
unsigned getVGPRTuplesWeight (unsigned AddressableArchVGPR) const {
98
115
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);
106
121
107
122
return std::max (Value[TOTAL_KINDS + VGPR] + AVGPRsAsVGPRs,
108
123
Value[TOTAL_KINDS + AGPR] + AVGPRsAsAGPRs);
0 commit comments