Skip to content

Commit 813479a

Browse files
committed
update tests
1 parent 269cb63 commit 813479a

File tree

97 files changed

+2052
-1636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2052
-1636
lines changed

clang/test/CodeGen/msp430-abi-complex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ float _Complex complex_float_res(void) {
202202
// CHECK-DAG: clr r12
203203
// CHECK-DAG: mov #16256, r13
204204
__imag__ res = -1;
205-
// CHECK-DAG: clr r14
205+
// CHECK-DAG: mov r12, r14
206206
// CHECK-DAG: mov #-16512, r15
207207
return res;
208208
// CHECK: ret

llvm/lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,8 @@ 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+
13311333
if (DstReg.isPhysical()) {
13321334
MachineBasicBlock *MBB = CopyMI->getParent();
13331335
if (DefMI->getParent() == MBB) {
@@ -1351,6 +1353,34 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
13511353
break;
13521354
// If there's a return instruction that uses this register, skip remat
13531355
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
1358+
if (DefMI->isMoveImmediate()) {
1359+
// Quick check: if there's only one use and it's this copy, definitely remat
1360+
if (MRI->hasOneNonDBGUse(SrcReg)) {
1361+
LLVM_DEBUG(dbgs() << "\tAllow remat: single use constant move\n");
1362+
break;
1363+
}
1364+
1365+
// Check all uses to see if they're all copies
1366+
bool OnlyUsedByCopies = true;
1367+
unsigned UseCount = 0;
1368+
for (const MachineOperand &MO : MRI->use_operands(SrcReg)) {
1369+
const MachineInstr *UseMI = MO.getParent(); // 改为 const
1370+
if (!UseMI->isCopy() && !UseMI->isSubregToReg()) {
1371+
OnlyUsedByCopies = false;
1372+
break;
1373+
}
1374+
UseCount++;
1375+
}
1376+
1377+
if (OnlyUsedByCopies && UseCount > 0) {
1378+
LLVM_DEBUG(dbgs() << "\tAllow remat: constant move only used by "
1379+
<< UseCount << " copies\n");
1380+
break; // Allow rematerialization
1381+
}
1382+
}
1383+
13541384
LLVM_DEBUG(dbgs() << "\tSkip remat for return register: "
13551385
<< printReg(DstReg, TRI) << '\n');
13561386
return false;

0 commit comments

Comments
 (0)