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]

Re: Don't let gen_lowpart generate SUBREGs with word -1.


On Nov 23, 2000, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Nov 22, 2000, Richard Henderson <rth@redhat.com> wrote:
>> On Wed, Nov 22, 2000 at 07:30:06PM -0200, Alexandre Oliva wrote:

>>> (gen_highpart): Abort on little-endian PARADOXICAL subreg.

>> I think it would make more sense to abort on any paradoxical highpart.

> I think I've given it a spin like that and it crashed because highpart
> is actually the lower bits when you're BIG_ENDIAN.  I'll try again.

It worked.  I must have tried something entirely different before.

Here's the new patch, bootstrapped on i686-pc-linux-gnu.  Ok to
install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* emit-rtl.c (gen_lowpart_common): Use word 0 if register mode
	is narrower than requested mode.
	(gen_highpart): Abort if register mode is narrower than
	requested mode.

Index: gcc/emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.154
diff -u -p -r1.154 emit-rtl.c
--- gcc/emit-rtl.c 2000/11/10 16:01:13 1.154
+++ gcc/emit-rtl.c 2000/11/23 08:36:37
@@ -709,7 +709,8 @@ gen_lowpart_common (mode, x)
 	 regs are sized by the underlying register size.  Better would be
 	 to always interpret the subreg offset parameter as bytes or bits.  */
 
-      if (WORDS_BIG_ENDIAN && REGNO (x) < FIRST_PSEUDO_REGISTER)
+      if (WORDS_BIG_ENDIAN && REGNO (x) < FIRST_PSEUDO_REGISTER
+	  && GET_MODE_SIZE (GET_MODE (x)) > GET_MODE_SIZE (mode))
 	word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
 		- HARD_REGNO_NREGS (REGNO (x), mode));
 
@@ -1141,7 +1142,9 @@ gen_highpart (mode, x)
 	 regs are sized by the underlying register size.  Better would be
 	 to always interpret the subreg offset parameter as bytes or bits.  */
 
-      if (WORDS_BIG_ENDIAN)
+      if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (mode))
+	abort ();
+      else if (WORDS_BIG_ENDIAN)
 	word = 0;
       else if (REGNO (x) < FIRST_PSEUDO_REGISTER)
 	word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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