Skip to content

Commit c75b24e

Browse files
committed
[AMDGPU] Track AV Register Pressure separately
Change-Id: Ifcd242c111b139f62109b12b588bb6af764fe4df
1 parent d737fe2 commit c75b24e

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ bool llvm::isEqual(const GCNRPTracker::LiveRegSet &S1,
3838

3939
unsigned GCNRegPressure::getRegKind(const TargetRegisterClass *RC,
4040
const SIRegisterInfo *STI) {
41-
return STI->isSGPRClass(RC) ? SGPR : (STI->isAGPRClass(RC) ? AGPR : VGPR);
41+
return STI->isSGPRClass(RC)
42+
? SGPR
43+
: (STI->isAGPRClass(RC)
44+
? AGPR
45+
: (STI->isVectorSuperClass(RC) ? AVGPR : VGPR));
4246
}
4347

4448
void GCNRegPressure::inc(unsigned Reg,

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,58 @@ class raw_ostream;
2929
class SlotIndex;
3030

3131
struct GCNRegPressure {
32-
enum RegKind { SGPR, VGPR, AGPR, TOTAL_KINDS };
32+
enum RegKind { SGPR, VGPR, AGPR, AVGPR, TOTAL_KINDS };
3333

3434
GCNRegPressure() {
3535
clear();
3636
}
3737

38-
bool empty() const { return !Value[SGPR] && !Value[VGPR] && !Value[AGPR]; }
38+
bool empty() const {
39+
return !Value[SGPR] && !Value[VGPR] && !Value[AGPR] && !Value[AVGPR];
40+
}
3941

4042
void clear() { std::fill(&Value[0], &Value[ValueArraySize], 0); }
4143

4244
/// \returns the SGPR32 pressure
4345
unsigned getSGPRNum() const { return Value[SGPR]; }
44-
/// \returns the aggregated ArchVGPR32, AccVGPR32 pressure dependent upon \p
45-
/// UnifiedVGPRFile
46+
/// \returns the aggregated ArchVGPR32, AccVGPR32, and Pseudo AVGPR pressure
47+
/// dependent upon \p UnifiedVGPRFile
4648
unsigned getVGPRNum(bool UnifiedVGPRFile) const {
4749
if (UnifiedVGPRFile) {
48-
return Value[AGPR] ? getUnifiedVGPRNum(Value[VGPR], Value[AGPR])
49-
: Value[VGPR];
50+
return Value[AGPR]
51+
? getUnifiedVGPRNum(Value[VGPR], Value[AGPR], Value[AVGPR])
52+
: Value[VGPR] + Value[AVGPR];
5053
}
51-
return std::max(Value[VGPR], Value[AGPR]);
54+
// Until we hit the VGPRThreshold, we will assign AV as VGPR. After that
55+
// point, we will assign as AGPR.
56+
return std::max(Value[VGPR] + Value[AVGPR], Value[AGPR]);
5257
}
5358

5459
/// Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
55-
/// and \p NumAGPRs AGPRS, for a target with a unified VGPR file.
60+
/// \p NumAGPRs AGPRS, and \p NumAVGPRs AVGPRs for a target with a unified
61+
/// VGPR file.
5662
inline static unsigned getUnifiedVGPRNum(unsigned NumArchVGPRs,
57-
unsigned NumAGPRs) {
58-
return alignTo(NumArchVGPRs, AMDGPU::IsaInfo::getArchVGPRAllocGranule()) +
63+
unsigned NumAGPRs,
64+
unsigned NumAVGPRs) {
65+
66+
// Until we hit the VGPRThreshold, we will assign AV as VGPR. After that
67+
// point, we will assign as AGPR.
68+
return alignTo(NumArchVGPRs + NumAVGPRs,
69+
AMDGPU::IsaInfo::getArchVGPRAllocGranule()) +
5970
NumAGPRs;
6071
}
6172

62-
/// \returns the ArchVGPR32 pressure
63-
unsigned getArchVGPRNum() const { return Value[VGPR]; }
73+
/// \returns the ArchVGPR32 pressure, plus the AVGPRS which we assume will be
74+
/// allocated as VGPR
75+
unsigned getArchVGPRNum() const { return Value[VGPR] + Value[AVGPR]; }
6476
/// \returns the AccVGPR32 pressure
6577
unsigned getAGPRNum() const { return Value[AGPR]; }
78+
/// \returns the AVGPR32 pressure
79+
unsigned getAVGPRNum() const { return Value[AVGPR]; }
6680

6781
unsigned getVGPRTuplesWeight() const {
68-
return std::max(Value[TOTAL_KINDS + VGPR], Value[TOTAL_KINDS + AGPR]);
82+
return std::max(Value[TOTAL_KINDS + VGPR] + Value[TOTAL_KINDS + AVGPR],
83+
Value[TOTAL_KINDS + AGPR]);
6984
}
7085
unsigned getSGPRTuplesWeight() const { return Value[TOTAL_KINDS + SGPR]; }
7186

0 commit comments

Comments
 (0)