[PATCH] D48582: Reverse subregister saved loops in register usage info collector.
Dave Airlie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 25 20:10:55 PDT 2018
airlied created this revision.
Herald added subscribers: llvm-commits, tpr.
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
Repository:
rL LLVM
https://reviews.llvm.org/D48582
Files:
lib/CodeGen/RegUsageInfoCollector.cpp
Index: lib/CodeGen/RegUsageInfoCollector.cpp
===================================================================
--- lib/CodeGen/RegUsageInfoCollector.cpp
+++ lib/CodeGen/RegUsageInfoCollector.cpp
@@ -171,28 +171,27 @@
}
// Insert any register fully saved via subregisters.
- for (unsigned PReg = 1, PRegE = TRI->getNumRegs(); PReg < PRegE; ++PReg) {
- if (SavedRegs.test(PReg))
+ 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;
-
- // 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);
+ for (unsigned PReg = 1, PRegE = TRI->getNumRegs(); PReg < PRegE; ++PReg) {
+ if (SavedRegs.test(PReg))
+ continue;
+
+ // 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);
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48582.152829.patch
Type: text/x-patch
Size: 1709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180626/87e5675b/attachment.bin>
More information about the llvm-commits
mailing list