[llvm] r340993 - Reverse subregister saved loops in register usage info collector; NFC
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 29 16:12:42 PDT 2018
Author: matze
Date: Wed Aug 29 16:12:42 2018
New Revision: 340993
URL: http://llvm.org/viewvc/llvm-project?rev=340993&view=rev
Log:
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
Modified:
llvm/trunk/lib/CodeGen/RegUsageInfoCollector.cpp
Modified: llvm/trunk/lib/CodeGen/RegUsageInfoCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegUsageInfoCollector.cpp?rev=340993&r1=340992&r2=340993&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegUsageInfoCollector.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegUsageInfoCollector.cpp Wed Aug 29 16:12:42 2018
@@ -166,28 +166,27 @@ computeCalleeSavedRegs(BitVector &SavedR
}
// Insert any register fully saved via subregisters.
- for (unsigned PReg = 1, PRegE = TRI.getNumRegs(); PReg < PRegE; ++PReg) {
- if (SavedRegs.test(PReg))
- continue;
+ for (const TargetRegisterClass *RC : TRI.regclasses()) {
+ if (!RC->CoveredBySubRegs)
+ continue;
- // Check if PReg is fully covered by its subregs.
- bool CoveredBySubRegs = false;
- for (const TargetRegisterClass *RC : TRI.regclasses())
- if (RC->CoveredBySubRegs && RC->contains(PReg)) {
- CoveredBySubRegs = true;
- break;
- }
- if (!CoveredBySubRegs)
- continue;
+ for (unsigned PReg = 1, PRegE = TRI.getNumRegs(); PReg < PRegE; ++PReg) {
+ if (SavedRegs.test(PReg))
+ continue;
- // Add PReg to SavedRegs if all subregs are saved.
- bool AllSubRegsSaved = true;
- for (MCSubRegIterator SR(PReg, &TRI, false); SR.isValid(); ++SR)
- if (!SavedRegs.test(*SR)) {
- AllSubRegsSaved = false;
- break;
- }
- if (AllSubRegsSaved)
- SavedRegs.set(PReg);
+ // Check if PReg is fully covered by its subregs.
+ if (!RC->contains(PReg))
+ continue;
+
+ // Add PReg to SavedRegs if all subregs are saved.
+ bool AllSubRegsSaved = true;
+ for (MCSubRegIterator SR(PReg, &TRI, false); SR.isValid(); ++SR)
+ if (!SavedRegs.test(*SR)) {
+ AllSubRegsSaved = false;
+ break;
+ }
+ if (AllSubRegsSaved)
+ SavedRegs.set(PReg);
+ }
}
}
More information about the llvm-commits
mailing list