Skip to content

Commit 84dbe57

Browse files
[AMDGPU] Use std::array in GCNRegPressure (NFC) (#164117)
With std::array, we can simplify clear and operator==.
1 parent 6e92f7e commit 84dbe57

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "llvm/CodeGen/LiveIntervals.h"
2222
#include "llvm/CodeGen/RegisterPressure.h"
2323
#include <algorithm>
24+
#include <array>
2425

2526
namespace llvm {
2627

@@ -45,7 +46,7 @@ struct GCNRegPressure {
4546
return !Value[SGPR] && !Value[VGPR] && !Value[AGPR] && !Value[AVGPR];
4647
}
4748

48-
void clear() { std::fill(&Value[0], &Value[ValueArraySize], 0); }
49+
void clear() { Value.fill(0); }
4950

5051
unsigned getNumRegs(RegKind Kind) const {
5152
assert(Kind < TOTAL_KINDS);
@@ -127,9 +128,7 @@ struct GCNRegPressure {
127128
bool less(const MachineFunction &MF, const GCNRegPressure &O,
128129
unsigned MaxOccupancy = std::numeric_limits<unsigned>::max()) const;
129130

130-
bool operator==(const GCNRegPressure &O) const {
131-
return std::equal(&Value[0], &Value[ValueArraySize], O.Value);
132-
}
131+
bool operator==(const GCNRegPressure &O) const { return Value == O.Value; }
133132

134133
bool operator!=(const GCNRegPressure &O) const {
135134
return !(*this == O);
@@ -160,7 +159,7 @@ struct GCNRegPressure {
160159

161160
/// Pressure for all register kinds (first all regular registers kinds, then
162161
/// all tuple register kinds).
163-
unsigned Value[ValueArraySize];
162+
std::array<unsigned, ValueArraySize> Value;
164163

165164
static unsigned getRegKind(const TargetRegisterClass *RC,
166165
const SIRegisterInfo *STI);

0 commit comments

Comments
 (0)