Skip to content

Commit 3c2b1f3

Browse files
committed
Tests
1 parent 6854976 commit 3c2b1f3

File tree

3 files changed

+1029
-1
lines changed

3 files changed

+1029
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPUHotBlockRematerialize.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
using namespace llvm;
3333

34+
static cl::opt<bool>
35+
EnableAggressive("amdgpu-remat-enable-hot-block-remat-aggressive");
3436
static cl::opt<unsigned> TargetOccupancy("amdgpu-remat-target-occupancy");
3537

3638
namespace {
@@ -723,6 +725,12 @@ int rematGain(MachineInstr *DefMI, unsigned Reg, const MachineRegisterInfo &MRI,
723725
if (IsSingleDef) {
724726
// The reg might share with other candidates, check It here.
725727
// Count share reg in getReducedSize.
728+
if (EnableAggressive) {
729+
// In case of aggressive remat, treat multi use reg as shared reg and
730+
// ignore size of shared reg.
731+
if (!MRI.hasOneNonDBGUse(Reg))
732+
continue;
733+
}
726734
const TargetRegisterClass *OpRC = MRI.getRegClass(Reg);
727735
if (unsigned SubIdx = MO.getSubReg()) {
728736
if (OpRC)
@@ -1253,6 +1261,9 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF, MachineLoop
12531261
unsigned SLimit = Status.TargetSLimit;
12541262

12551263
int RematSCnt = Status.MaxSPressure - SLimit;
1264+
// when agressive sgpr remat, reserve some for allocation lost.
1265+
if (EnableAggressive)
1266+
RematSCnt += NearTargetRegLimit;
12561267

12571268
bool IsSGPRSpill = false;
12581269
if (RematSCnt > 0) {
@@ -1367,7 +1378,7 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF, MachineLoop
13671378
for (RematNode &Node : SRematList) {
13681379
SRematMap[Node.Reg] = Node;
13691380
RematCnt += Node.Size;
1370-
if (RematCnt > RematSCnt)
1381+
if (RematCnt > RematSCnt && !EnableAggressive)
13711382
break;
13721383
}
13731384
NewRematSCnt = 0;

0 commit comments

Comments
 (0)