Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 460e601

Browse files
committed
Reverse subregister saved loops in register usage info collector; NFC
On AMDGPU we have 70 register classes, so iterating over all 70 each time and exiting is costly on the CPU, this flips the loop around so that it loops over the 70 register classes first, and exits without doing the inner loop if needed. On my test just starting radv this takes RegUsageInfoCollector::runOnMachineFunction from 6.0% of total time to 2.7% of total time, and reduces the startup from 2.24s to 2.19s Patch by David Airlie! Differential Revision: https://reviews.llvm.org/D48582 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340993 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ff8943d commit 460e601

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

lib/CodeGen/RegUsageInfoCollector.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,27 @@ computeCalleeSavedRegs(BitVector &SavedRegs, MachineFunction &MF) {
166166
}
167167

168168
// Insert any register fully saved via subregisters.
169-
for (unsigned PReg = 1, PRegE = TRI.getNumRegs(); PReg < PRegE; ++PReg) {
170-
if (SavedRegs.test(PReg))
171-
continue;
172-
173-
// Check if PReg is fully covered by its subregs.
174-
bool CoveredBySubRegs = false;
175-
for (const TargetRegisterClass *RC : TRI.regclasses())
176-
if (RC->CoveredBySubRegs && RC->contains(PReg)) {
177-
CoveredBySubRegs = true;
178-
break;
179-
}
180-
if (!CoveredBySubRegs)
181-
continue;
182-
183-
// Add PReg to SavedRegs if all subregs are saved.
184-
bool AllSubRegsSaved = true;
185-
for (MCSubRegIterator SR(PReg, &TRI, false); SR.isValid(); ++SR)
186-
if (!SavedRegs.test(*SR)) {
187-
AllSubRegsSaved = false;
188-
break;
189-
}
190-
if (AllSubRegsSaved)
191-
SavedRegs.set(PReg);
169+
for (const TargetRegisterClass *RC : TRI.regclasses()) {
170+
if (!RC->CoveredBySubRegs)
171+
continue;
172+
173+
for (unsigned PReg = 1, PRegE = TRI.getNumRegs(); PReg < PRegE; ++PReg) {
174+
if (SavedRegs.test(PReg))
175+
continue;
176+
177+
// Check if PReg is fully covered by its subregs.
178+
if (!RC->contains(PReg))
179+
continue;
180+
181+
// Add PReg to SavedRegs if all subregs are saved.
182+
bool AllSubRegsSaved = true;
183+
for (MCSubRegIterator SR(PReg, &TRI, false); SR.isValid(); ++SR)
184+
if (!SavedRegs.test(*SR)) {
185+
AllSubRegsSaved = false;
186+
break;
187+
}
188+
if (AllSubRegsSaved)
189+
SavedRegs.set(PReg);
190+
}
192191
}
193192
}

0 commit comments

Comments
 (0)