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] fix ix86 prefetch support with -Os


This patch allows -fprefetch-loop-arrays to work with -Os on ix86
targets.  The function emit_prefetch_instructions in loop.c uses two
target-specific parameters, PREFETCH_BLOCK and SIMULTANEOUS_PREFETCHES,
which for ix86 targets come from a structure of costs that is different
for each cpu type, with a separate set of costs for size optimization.
The prefetch parameters should still come from the target information
event with -Os, so this patch copies the values for the cpu type into
global variables that the macros PREFETCH_BLOCK and
SIMULTANEOUS_PREFETCHES now reference instead of the value from the cost
structure.

Bootstrapped and tested on i686-pc-linux-gnu.  OK to commit?

2002-01-15  Janis Johnson  <janis187@us.ibm.com>

	* config/i386/i386.c (ix86_prefetch_block): Define new global variable.
	(ix86_simultaneous_prefetches): Define new global variable.
	(override_options): Get prefetch parameters from cpu table.
	* config/i386/i386.h (ix86_prefetch_block): Declare global variable.
	(ix86_simultaneous_prefetches): Declare global variable.
	(PREFETCH_BLOCK): Use ix86_prefetch_block.
	(SIMULTANEOUS_PREFETCHES): Use ix86_simultaneous_prefetches.

testsuite:

2002-01-15  Janis Johnson  <janis187@us.ibm.com>
	* gcc.dg/20020115-1.c: New test.

Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.358
diff -u -p -r1.358 i386.c
--- i386.c	2002/01/15 13:13:21	1.358
+++ i386.c	2002/01/15 17:37:55
@@ -345,6 +345,8 @@ struct processor_costs pentium4_cost = {
 };
 
 const struct processor_costs *ix86_cost = &pentium_cost;
+int ix86_prefetch_block;
+int ix86_simultaneous_prefetches;
 
 /* Processor feature/optimization bitmasks.  */
 #define m_386 (1<<PROCESSOR_I386)
@@ -1001,6 +1003,10 @@ override_options ()
     ix86_cost = &size_cost;
   else
     ix86_cost = processor_target_table[ix86_cpu].cost;
+  ix86_prefetch_block =
+	processor_target_table[ix86_cpu].cost->prefetch_block;
+  ix86_simultaneous_prefetches =
+	processor_target_table[ix86_cpu].cost->simultaneous_prefetches;
   target_flags |= processor_target_table[ix86_cpu].target_enable;
   target_flags &= ~processor_target_table[ix86_cpu].target_disable;
 
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.237
diff -u -p -r1.237 i386.h
--- i386.h	2002/01/12 10:05:26	1.237
+++ i386.h	2002/01/15 17:38:10
@@ -92,6 +92,8 @@ struct processor_costs {
 };
 
 extern const struct processor_costs *ix86_cost;
+extern int ix86_prefetch_block;
+extern int ix86_simultaneous_prefetches;
 
 /* Run-time compilation parameters selecting different hardware subsets.  */
 
@@ -2316,10 +2318,10 @@ do {								\
 #define DEFAULT_SIGNED_CHAR 1
 
 /* Number of bytes moved into a data cache for a single prefetch operation.  */
-#define PREFETCH_BLOCK ix86_cost->prefetch_block
+#define PREFETCH_BLOCK ix86_prefetch_block
 
 /* Number of prefetch operations that can be done in parallel.  */
-#define SIMULTANEOUS_PREFETCHES ix86_cost->simultaneous_prefetches
+#define SIMULTANEOUS_PREFETCHES ix86_simultaneous_prefetches
 
 /* Max number of bytes we can move from memory to memory
    in one reasonably fast instruction.  */
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/20020115-1.c	Tue Jan 15 09:39:07 2002
@@ -0,0 +1,13 @@
+/* Check that non-zero prefetch parameters are defined for ix86 targets
+   for use with -Os.  */
+
+/* { dg-do compile { target i?86-*-* } } */
+/* { dg-options "-Os -fprefetch-loop-arrays -mcpu=pentium3" } */
+
+int foo (int *p, int n)
+{
+  int i, r;
+  for (i = 0; i < n; i++)
+    r += p[i];
+  return r;
+}


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