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]

combine-created negative subreg_byte wreaks havoc in reload


gcc.c-torture/compile/20021124-1.c triggers an error in combine
similar to that fixed by Dale Johannesen on 2002-09-19, except that in
this case, on a big-endian port, the byte count ends up negative,
which leads to an ugly error in reload, in which choose_reload_regs
computes a register number as 0 (the hardware register assigned to the
pseudo enclosed in the subreg) plus -2 (the subreg byte) converted to
words through an unsigned division, so it ends up trying to load
reg_last_reload_reg[0x7fffffff].  Oops.  Fixed as follows.  Ok to
install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva at redhat dot com>

	* combine.c (make_extraction): Prevent formation of subregs with
	negative subreg byte.

Index: gcc/combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.342
diff -u -p -r1.342 combine.c
--- gcc/combine.c 20 Feb 2003 20:56:51 -0000 1.342
+++ gcc/combine.c 22 Feb 2003 08:48:02 -0000
@@ -6242,7 +6242,8 @@ make_extraction (mode, inner, pos, pos_r
 
 	      /* Avoid creating invalid subregs, for example when
 		 simplifying (x>>32)&255.  */
-	      if (final_word >= GET_MODE_SIZE (inner_mode))
+	      if (final_word >= GET_MODE_SIZE (inner_mode)
+		  || final_word < 0)
 		return NULL_RTX;
 
 	      new = gen_rtx_SUBREG (tmode, inner, final_word);
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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