@@ -176,21 +176,17 @@ DenseMap<MachineBasicBlock *, BlockSet> reduceClonedMBBs(
176176 bool IsDomAllHotBlocks = true ;
177177 bool IsDomedByAllHotBlocks = true ;
178178 for (MachineBasicBlock *HotMBB : HotBlockSet) {
179- if (!DT->dominates (MBB, HotMBB)) {
179+ if (!DT->dominates (MBB, HotMBB))
180180 IsDomAllHotBlocks = false ;
181- }
182- if (!DT->dominates (HotMBB, MBB)) {
181+ if (!DT->dominates (HotMBB, MBB))
183182 IsDomedByAllHotBlocks = false ;
184- }
185- if (!IsDomAllHotBlocks && !IsDomedByAllHotBlocks) {
183+ if (!IsDomAllHotBlocks && !IsDomedByAllHotBlocks)
186184 break ;
187- }
188185 }
189- if (IsDomAllHotBlocks) {
186+ if (IsDomAllHotBlocks)
190187 UserBlocks.erase (MBB);
191- } else if (IsDomedByAllHotBlocks) {
188+ else if (IsDomedByAllHotBlocks)
192189 AfterHotRangeMBBs.insert (MBB);
193- }
194190 }
195191
196192 // Split after hotRange block set by domtree.
@@ -274,18 +270,16 @@ void AMDGPUHotBlockRematerialize::applyCloneRemat(
274270 for (auto UseIt : UserMap) {
275271 MachineBasicBlock *MBB = UseIt.first ;
276272 // Skip same block uses.
277- if (MBB == DefMI->getParent ()) {
273+ if (MBB == DefMI->getParent ())
278274 continue ;
279- }
280275 // Skip MBB which share clone from other MBBs.
281276 if (UserMBBSet.count (MBB) == 0 )
282277 continue ;
283278
284279 Register NewReg = MRI.createVirtualRegister (RC);
285280 auto NewDef = BuildMI (MF, DL, Desc).addDef (NewReg);
286- for (unsigned I = 1 ; I < OpNum; I++) {
281+ for (unsigned I = 1 ; I < OpNum; I++)
287282 NewDef = NewDef.add (DefMI->getOperand (I));
288- }
289283
290284 MachineInstr *InsertPointMI = UseIt.second .front ();
291285 SlotIndex LastSlot = SlotIndexes->getInstructionIndex (*InsertPointMI);
@@ -364,9 +358,9 @@ void AMDGPUHotBlockRematerialize::applyRemat(
364358 llvm::SlotIndexes *SlotIndexes, MachineRegisterInfo &MRI,
365359 const SIRegisterInfo *SIRI, const SIInstrInfo *SIII, MachineFunction &MF) {
366360 std::vector<RematNode> UpdateList;
367- for (auto &It : RematMap) {
361+ for (auto &It : RematMap)
368362 UpdateList.emplace_back (It.second );
369- }
363+
370364 // Sort update list with slotIndex to make sure def moved before use.
371365 // If use moved before def, It might not be the first use anymore.
372366 std::sort (UpdateList.begin (), UpdateList.end (),
@@ -377,11 +371,10 @@ void AMDGPUHotBlockRematerialize::applyRemat(
377371 });
378372
379373 for (RematNode &Node : UpdateList) {
380- if (Node.Kind == RematNode::RematKind::OneDefOneUse) {
374+ if (Node.Kind == RematNode::RematKind::OneDefOneUse)
381375 applyOneDefOneUseRemat (Node, MRI, SlotIndexes, SIRI, SIII);
382- } else if (Node.Kind == RematNode::RematKind::Clone) {
376+ else if (Node.Kind == RematNode::RematKind::Clone)
383377 applyCloneRemat (Node, HotBlocks, DT, MRI, SlotIndexes, SIRI, SIII, MF);
384- }
385378 }
386379}
387380
@@ -410,12 +403,10 @@ unsigned collectMBBPressure(MachineBasicBlock &MBB, LiveIntervals *LIS,
410403
411404 GCNRegPressure RP = RPTracker.getMaxPressureAndReset ();
412405 unsigned SPressure = RP.getMaxSGPR ();
413- if (SPressure > MaxSPressure) {
406+ if (SPressure > MaxSPressure)
414407 MaxSPressure = SPressure;
415- }
416- if (RP.getVGPRNum (ST->hasGFX90AInsts ()) > MaxVPressure) {
408+ if (RP.getVGPRNum (ST->hasGFX90AInsts ()) > MaxVPressure)
417409 MaxVPressure = RP.getVGPRNum (ST->hasGFX90AInsts ());
418- }
419410 Status.MBBPressureMap [&MBB] = RP;
420411 return RP.getOccupancy (*ST);
421412}
@@ -573,9 +564,8 @@ RematStatus getRematStatus(MachineFunction &MF, MachineLoopInfo *MLI,
573564 unsigned SInputPressure = 0 ;
574565 uint64_t Mask = 0xf ;
575566 while (Mask != 0 ) {
576- if (Mask & SInputMask) {
567+ if (Mask & SInputMask)
577568 SInputPressure += 4 ;
578- }
579569 Mask = Mask << 4 ;
580570 }
581571
@@ -670,9 +660,8 @@ void updateLiveInfo(MapVector<Register, RematNode> &RematMap,
670660 // still before LiveInfo.BB, It is still live.
671661 unsigned LiveBBIndex = RPOTIndexMap[CurBB];
672662 unsigned InsertBBIndex = RPOTIndexMap[InsertBB];
673- if (LiveBBIndex > InsertBBIndex) {
663+ if (LiveBBIndex > InsertBBIndex)
674664 continue ;
675- }
676665 }
677666 // Already in remat map, don't need to check again, remove from
678667 // candidate.
@@ -978,11 +967,10 @@ void buildRematCandiates(std::vector<RematNode> &Candidates,
978967
979968 if (IsSafeCandidate) {
980969 int Gain = rematGain (MI, Reg, MRI, SIRI, IsVGPR);
981- if (Gain > 0 ) {
970+ if (Gain > 0 )
982971 Candidates.emplace_back (RematNode (Reg, MI, Gain >> 5 ));
983- } else {
972+ else
984973 IsSafeCandidate = false ;
985- }
986974 }
987975 // Save unsafe reg.
988976 if (!IsSafeCandidate)
@@ -1056,9 +1044,9 @@ int filterRematCandiates(std::vector<RematNode> &Candidates,
10561044 // Work one def one use first.
10571045 for (auto &Node : Candidates) {
10581046 unsigned Reg = Node.Reg ;
1059- if (!MRI.hasOneNonDBGUse (Reg)) {
1047+ if (!MRI.hasOneNonDBGUse (Reg))
10601048 continue ;
1061- }
1049+
10621050 MachineInstr *DefMI = Node.DefMI ;
10631051 if (!isSafeToMove (DefMI, MRI)) {
10641052 PinnedRegSet.insert (Reg);
@@ -1074,9 +1062,9 @@ int filterRematCandiates(std::vector<RematNode> &Candidates,
10741062 // Try multi use case.
10751063 for (auto &Node : Candidates) {
10761064 unsigned Reg = Node.Reg ;
1077- if (MRI.hasOneNonDBGUse (Reg)) {
1065+ if (MRI.hasOneNonDBGUse (Reg))
10781066 continue ;
1079- }
1067+
10801068 MachineInstr *DefMI = Node.DefMI ;
10811069 if (!isSafeToMove (DefMI, MRI)) {
10821070 PinnedRegSet.insert (Reg);
@@ -1161,10 +1149,9 @@ int getSharedReducedSize(InstSet &ReducedInsts, bool IsVGPR,
11611149 if (!Reg.isVirtual ())
11621150 continue ;
11631151
1164- if (IsVGPR != SIRI->isVGPR (MRI, MO.getReg ())) {
1152+ if (IsVGPR != SIRI->isVGPR (MRI, MO.getReg ()))
11651153 // Not support mix of v and s when remat now.
11661154 continue ;
1167- }
11681155
11691156 const TargetRegisterClass *OpRC = MRI.getRegClass (Reg);
11701157 int MOSize = SIRI->getRegSizeInBits (*OpRC) >> 5 ;
@@ -1245,9 +1232,8 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF,
12451232
12461233 ReversePostOrderTraversal<MachineFunction *> RPOT (&MF);
12471234 DenseMap<MachineBasicBlock *, unsigned > RPOTIndexMap;
1248- for (MachineBasicBlock *MBB : RPOT) {
1235+ for (MachineBasicBlock *MBB : RPOT)
12491236 RPOTIndexMap[MBB] = RPOTIndexMap.size ();
1250- }
12511237
12521238 auto &MRI = MF.getRegInfo ();
12531239
@@ -1267,9 +1253,8 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF,
12671253 RematSCnt += NearTargetRegLimit;
12681254
12691255 bool IsSGPRSpill = false ;
1270- if (RematSCnt > 0 ) {
1256+ if (RematSCnt > 0 )
12711257 IsSGPRSpill = nearSgprSpill (Status.MaxSPressure , ST, MF);
1272- }
12731258
12741259 const bool IsForceRematSgpr = IsSGPRSpill || Status.NotBalance ;
12751260
@@ -1354,9 +1339,9 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF,
13541339 int RematSCnt = MaxSPressure - SReduced - SLimit;
13551340
13561341 bool IsSGPRSpill = false ;
1357- if (RematSCnt > 0 ) {
1342+ if (RematSCnt > 0 )
13581343 IsSGPRSpill = nearSgprSpill (MaxSPressure, ST, MF);
1359- }
1344+
13601345 bool IsForceRematSgpr = IsSGPRSpill || Status.NotBalance ;
13611346 // Try to add candidates into remat list.
13621347
@@ -1393,15 +1378,13 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF,
13931378 getSharedReducedSize (SReducedInsts, /* IsVGPR*/ false , MRI, SIRI);
13941379 if (((NewRematSCnt + SharedReducedSize) + (int )NearTargetRegLimit) >=
13951380 RematSCnt) {
1396- for (RematNode &Node : SRematList) {
1381+ for (RematNode &Node : SRematList)
13971382 SRematMap[Node.Reg ] = Node;
1398- }
13991383 } else {
14001384 if (!IsForceRematSgpr)
14011385 return false ;
1402- for (RematNode &Node : SRematList) {
1386+ for (RematNode &Node : SRematList)
14031387 SRematMap[Node.Reg ] = Node;
1404- }
14051388 // Find local one def one use candidates.
14061389 for (MachineInstr &MI : *MBB) {
14071390 if (MI.isDebugInstr ())
@@ -1425,9 +1408,8 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF,
14251408 /* IsVGPR*/ false );
14261409 if (Gain > 0 ) {
14271410 // Skip case when DefMI has implicit define which used by UseMI.
1428- if (isImplicitDefUse (&MI, &UseMI)) {
1411+ if (isImplicitDefUse (&MI, &UseMI))
14291412 continue ;
1430- }
14311413 RematNode Node = {Reg, &MI, (unsigned )Gain >> 5 };
14321414 Node.InsertPointMI = &UseMI;
14331415 Node.Kind = RematNode::RematKind::OneDefOneUse;
@@ -1459,19 +1441,16 @@ bool AMDGPUHotBlockRematerialize::hotBlockRemat(MachineFunction &MF,
14591441 bool IsVRematOK =
14601442 (Status.NotBalance || NewRematVCnt <= 0 ) && !VRematMap.empty ();
14611443 if (NeedSRemat && NeedVRemat) {
1462- if (IsVRematOK && IsSRematOK) {
1444+ if (IsVRematOK && IsSRematOK)
14631445 IsUpdated = true ;
1464- } else if (IsSGPRSpill) {
1446+ else if (IsSGPRSpill)
14651447 IsUpdated = true ;
1466- }
14671448 } else if (NeedSRemat) {
1468- if (IsSRematOK) {
1449+ if (IsSRematOK)
14691450 IsUpdated = true ;
1470- }
14711451 } else if (NeedVRemat) {
1472- if (IsVRematOK) {
1452+ if (IsVRematOK)
14731453 IsUpdated = true ;
1474- }
14751454 }
14761455 // TODO: what to do when cannot reach target?
14771456 if (NewRematSCnt > 0 ) {
0 commit comments