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]

Re: [PR rtl-optimization/20532] plus(ashift,ashift) -> mult may overflow


On Mar 24, 2005, Jakub Jelinek <jakub@redhat.com> wrote:

> On Thu, Mar 24, 2005 at 06:39:00AM -0300, Alexandre Oliva wrote:
>> > If you want -m32 -march=i386 specifically for IA-32, you can put it
>> > into gcc.dg/torture and use something like:
>> 
>> I also needed at least -O1 to trigger the bug, and -m32 didn't

> gcc.dg/torture iterates over all optimization levels,

Aah, I'd completely missed the reference to the `torture' subdir.  I'm
checking this in, and adjusting the patch for 4.0.

Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>
	* gcc.dg/badshift.c: Renamed to...
	* gcc.dg/torture/badshift.c: ... this.  Remove explicit -O1.

Index: gcc/testsuite/gcc.dg/badshift.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/badshift.c
diff -N gcc/testsuite/gcc.dg/badshift.c
--- gcc/testsuite/gcc.dg/badshift.c 24 Mar 2005 09:38:15 -0000 1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-/* PR rtl-optimization/20532 */
-
-/* { dg-do run } */
-/* { dg-options "-O1" } */
-/* { dg-options "-march=i386 -O1" { target i?86-*-* } } */
-
-/* We used to optimize the DImode shift-by-32 to zero because in combine
-   we turned:
-
-     (v << 31) + (v << 31)
-
-   into:
-
-     (v * (((HOST_WIDE_INT)1 << 31) + ((HOST_WIDE_INT)1 << 31)))
-
-   With a 32-bit HOST_WIDE_INT, the coefficient overflowed to zero.  */
-
-unsigned long long int badshift(unsigned long long int v)
-{
-        return v << 31 << 1;
-}
-
-extern void abort ();
-
-int main() {
-  if (badshift (1) == 0)
-    abort ();
-  return 0;
-}
Index: gcc/testsuite/gcc.dg/torture/badshift.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/torture/badshift.c
diff -N gcc/testsuite/gcc.dg/torture/badshift.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/torture/badshift.c 24 Mar 2005 10:51:59 -0000
@@ -0,0 +1,29 @@
+/* PR rtl-optimization/20532 */
+
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-options "-march=i386" { target i?86-*-* } } */
+
+/* We used to optimize the DImode shift-by-32 to zero because in combine
+   we turned:
+
+     (v << 31) + (v << 31)
+
+   into:
+
+     (v * (((HOST_WIDE_INT)1 << 31) + ((HOST_WIDE_INT)1 << 31)))
+
+   With a 32-bit HOST_WIDE_INT, the coefficient overflowed to zero.  */
+
+unsigned long long int badshift(unsigned long long int v)
+{
+        return v << 31 << 1;
+}
+
+extern void abort ();
+
+int main() {
+  if (badshift (1) == 0)
+    abort ();
+  return 0;
+}
-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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