This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, i386]: Use array of regs instead of separate regs in detect_caches_cpuid2


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.
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]);
     }
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]