* [PATCH, i386]: Use array of regs instead of separate regs in detect_caches_cpuid2
@ 2008-10-12 19:26 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2008-10-12 19:26 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
Hello!
Just a trivial optimization that enables use of a for loop in
detect_caches_cpuid2.
2008-10-12 Uros Bizjak <ubizjak@gmail.com>
* config/i386/driver-i386.c (detect_caches_cpuid2): Use array
of registers instead of eax, ebx, ecx and edx. Use for loop
and check register for non-zero value before the call
to decode_caches_intel.
Bootstrapped and regression tested on x86_64-pc-linux-gnu, committed to
mainline.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1183 bytes --]
Index: driver-i386.c
===================================================================
--- driver-i386.c (revision 141064)
+++ driver-i386.c (working copy)
@@ -230,27 +230,22 @@ static void
detect_caches_cpuid2 (bool xeon_mp,
struct cache_desc *level1, struct cache_desc *level2)
{
- unsigned eax, ebx, ecx, edx;
- int nreps;
+ unsigned regs[4];
+ int nreps, i;
- __cpuid (2, eax, ebx, ecx, edx);
+ __cpuid (2, regs[0], regs[1], regs[2], regs[3]);
- nreps = eax & 0x0f;
- eax &= ~0x0f;
+ nreps = regs[0] & 0x0f;
+ regs[0] &= ~0x0f;
while (--nreps >= 0)
{
- if (!((eax >> 31) & 1))
- decode_caches_intel (eax, xeon_mp, level1, level2);
- if (!((ebx >> 31) & 1))
- decode_caches_intel (ebx, xeon_mp, level1, level2);
- if (!((ecx >> 31) & 1))
- decode_caches_intel (ecx, xeon_mp, level1, level2);
- if (!((edx >> 31) & 1))
- decode_caches_intel (edx, xeon_mp, level1, level2);
+ for (i = 0; i < 4; i++)
+ if (regs[i] && !((regs[i] >> 31) & 1))
+ decode_caches_intel (regs[i], xeon_mp, level1, level2);
if (nreps)
- __cpuid (2, eax, ebx, ecx, edx);
+ __cpuid (2, regs[0], regs[1], regs[2], regs[3]);
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-10-12 18:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-12 19:26 [PATCH, i386]: Use array of regs instead of separate regs in detect_caches_cpuid2 Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).