@@ -1328,8 +1328,6 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
13281328
13291329 // Skip rematerialization for physical registers used as return values within
13301330 // the same basic block to enable better coalescing.
1331-
1332-
13331331 if (DstReg.isPhysical ()) {
13341332 MachineBasicBlock *MBB = CopyMI->getParent ();
13351333 if (DefMI->getParent () == MBB) {
@@ -1353,34 +1351,35 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
13531351 break ;
13541352 // If there's a return instruction that uses this register, skip remat
13551353 if (MI.isReturn () && MI.readsRegister (DstReg, TRI)) {
1356- // Exception: if DefMI is moving a constant and SrcReg has no other uses
1357- // (besides copies), rematerialization is beneficial to eliminate the def
1354+ // Exception: if DefMI is moving a constant and SrcReg has no other
1355+ // uses (besides copies), rematerialization is beneficial to
1356+ // eliminate the def
13581357 if (DefMI->isMoveImmediate ()) {
1359- // Quick check: if there's only one use and it's this copy, definitely remat
1358+ // Quick check: if there's only one use and it's this copy,
1359+ // definitely remat
13601360 if (MRI->hasOneNonDBGUse (SrcReg)) {
1361- LLVM_DEBUG (dbgs () << " \t Allow remat: single use constant move\n " );
1361+ LLVM_DEBUG (dbgs ()
1362+ << " \t Allow remat: single use constant move\n " );
13621363 break ;
13631364 }
1364-
1365+
13651366 // Check all uses to see if they're all copies
13661367 bool OnlyUsedByCopies = true ;
13671368 unsigned UseCount = 0 ;
13681369 for (const MachineOperand &MO : MRI->use_operands (SrcReg)) {
1369- const MachineInstr *UseMI = MO.getParent (); // 改为 const
1370+ const MachineInstr *UseMI = MO.getParent ();
13701371 if (!UseMI->isCopy () && !UseMI->isSubregToReg ()) {
13711372 OnlyUsedByCopies = false ;
13721373 break ;
13731374 }
13741375 UseCount++;
13751376 }
1376-
1377+
13771378 if (OnlyUsedByCopies && UseCount > 0 ) {
1378- LLVM_DEBUG (dbgs () << " \t Allow remat: constant move only used by "
1379- << UseCount << " copies\n " );
1380- break ; // Allow rematerialization
1379+ break ;
13811380 }
13821381 }
1383-
1382+
13841383 LLVM_DEBUG (dbgs () << " \t Skip remat for return register: "
13851384 << printReg (DstReg, TRI) << ' \n ' );
13861385 return false ;
0 commit comments