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]

fix for shifts by most significant bits on bigendian system



Introduced by

Mon Dec 15 18:40:08 1997  Richard Henderson  <rth@cygnus.com>

	* expmed.c (expand_shift): If SHIFT_COUNT_TRUNCATED, drop a SUBREG.

and apparently the problem is rare enough that no-one ever noticed it
in four years.

Bootstrapped and tested on sparc-sun-solaris2.6.

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/gcc-shiftbigendian.patch==================
Index: ChangeLog
2002-02-25  Geoffrey Keating  <geoffk@redhat.com>

	* expmed.c (expand_shift): Correctly test for low part of a
	subreg.

Index: testsuite/ChangeLog
2002-02-25  Geoffrey Keating  <geoffk@redhat.com>

	* gcc.c-torture/execute/20020225-2.c: New test.

Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.108
diff -p -u -p -r1.108 expmed.c
--- expmed.c	2002/02/22 00:07:06	1.108
+++ expmed.c	2002/02/27 20:10:03
@@ -1913,7 +1913,7 @@ expand_shift (code, mode, shifted, amoun
         op1 = GEN_INT ((unsigned HOST_WIDE_INT) INTVAL (op1)
 		       % GET_MODE_BITSIZE (mode));
       else if (GET_CODE (op1) == SUBREG
-	       && SUBREG_BYTE (op1) == 0)
+	       && subreg_lowpart_p (op1))
 	op1 = SUBREG_REG (op1);
     }
 #endif
Index: testsuite/gcc.c-torture/execute/20020225-2.c
===================================================================
RCS file: 20020225-2.c
diff -N 20020225-2.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ 20020225-2.c	Wed Feb 27 12:10:14 2002
@@ -0,0 +1,19 @@
+static int 
+test(int x)
+{
+  union 
+    {
+      int i;
+      double d;
+  } a;
+  a.d = 0;
+  a.i = 1;
+  return x >> a.i;
+}
+
+int main(void)
+{
+  if (test (5) != 2)
+    abort ();
+  exit (0);
+}
============================================================


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