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] loop.c: check predicate of prefetch address operand


[I originally mailed this on January 17 but that mail is still within
IBM somewhere.  I've updated this one just a bit by adding a comment
before the new code.]

In http://gcc.gnu.org/ml/gcc-patches/2002-01/msg01117.html, Richard
Henderson recommended that the address being used in a prefetch
optimization be checked against the predicate and forced into a register
if necessary.  This was being done in expand_builtin_prefetch, but not
in emit_prefetch_instructions for -fprefetch-loop-arrays.  The second
call to gen_prefetch in that function already forced the address into a
REG.

Bootstrapped and tested on i686-pc-linux-gnu.  I don't have a test case
that passes with this patch but fails without, but the patch allows a
bootstrap with BOOT_CFLAGS="-g -O2 -fprefetch-loop-arrays -mcpu=pentium3"
to get a little further than it did without the patch.

OK?

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

	* Makefile.in
	* loop.c (expand_builtin_prefetch): Check the prefetch operand
	against the predicate.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.822
diff -u -p -r1.822 Makefile.in
--- Makefile.in	2002/01/13 12:28:39	1.822
+++ Makefile.in	2002/01/16 21:44:54
@@ -1470,7 +1470,7 @@ profile.o : profile.c $(CONFIG_H) $(SYST
 loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h $(LOOP_H) \
    insn-config.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) \
    real.h $(PREDICT_H) $(BASIC_BLOCK_H) function.h \
-   toplev.h varray.h except.h cselib.h $(TM_P_H)
+   toplev.h varray.h except.h cselib.h $(OPTABS_H) $(TM_P_H)
 doloop.o : doloop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h $(LOOP_H) \
    $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) $(TM_P_H) toplev.h
 unroll.o : unroll.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) insn-config.h function.h \
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.378
diff -u -p -r1.378 loop.c
--- loop.c	2002/01/03 16:05:54	1.378
+++ loop.c	2002/01/16 17:04:14
@@ -54,6 +54,7 @@ Software Foundation, 59 Temple Place - S
 #include "toplev.h"
 #include "predict.h"
 #include "insn-flags.h"
+#include "optabs.h"
 
 /* Not really meaningful values, but at least something.  */
 #ifndef SIMULTANEOUS_PREFETCHES
@@ -4019,6 +4020,10 @@ emit_prefetch_instructions (loop)
 		  loc = reg;
 		}
 
+	      /* Make sure the address operand is valid for prefetch.  */
+	      if (! (*insn_data[(int)CODE_FOR_prefetch].operand[0].predicate)
+		    (loc, Pmode))
+		loc = force_reg (Pmode, loc);
 	      emit_insn_before (gen_prefetch (loc, GEN_INT (info[i].write),
 		                              GEN_INT (3)),
 				before_insn);


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