* combine.c (nonzero_bits): Fix check for negative divide operands.
authorRichard Sandiford <rsandifo@redhat.com>
Tue, 28 Jan 2003 22:15:50 +0000 (22:15 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 28 Jan 2003 22:15:50 +0000 (22:15 +0000)
From-SVN: r62029

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20030128-1.c [new file with mode: 0644]

index 60de22da4e935ed16fa1c0a92f60e302e3e2c381..bc469656054fd9e02aff713f647ca512ec473681 100644 (file)
@@ -1,3 +1,7 @@
+2003-01-28  Richard Sandiford  <rsandifo@redhat.com>
+
+       * combine.c (nonzero_bits): Fix check for negative divide operands.
+
 2003-01-28  Richard Henderson  <rth@redhat.com>
 
        * config/ia64/ia64.c (ia64_rwreloc_section_type_flags): New.
index 4f03d008e7e4b7d19f90a883b259dc3f73735c9e..90c4482e33a466d9cd7dbf7fe6009fb387bb55e8 100644 (file)
@@ -8369,14 +8369,15 @@ nonzero_bits (x, mode)
       {
        unsigned HOST_WIDE_INT nz0 = nonzero_bits (XEXP (x, 0), mode);
        unsigned HOST_WIDE_INT nz1 = nonzero_bits (XEXP (x, 1), mode);
+       int sign_index = GET_MODE_BITSIZE (GET_MODE (x)) - 1;
        int width0 = floor_log2 (nz0) + 1;
        int width1 = floor_log2 (nz1) + 1;
        int low0 = floor_log2 (nz0 & -nz0);
        int low1 = floor_log2 (nz1 & -nz1);
        HOST_WIDE_INT op0_maybe_minusp
-         = (nz0 & ((HOST_WIDE_INT) 1 << (mode_width - 1)));
+         = (nz0 & ((HOST_WIDE_INT) 1 << sign_index));
        HOST_WIDE_INT op1_maybe_minusp
-         = (nz1 & ((HOST_WIDE_INT) 1 << (mode_width - 1)));
+         = (nz1 & ((HOST_WIDE_INT) 1 << sign_index));
        unsigned int result_width = mode_width;
        int result_low = 0;
 
index c2f60e6ede791ed58569484cd9a24869abb9c7ce..9e5ea48f89e39d0a97da6ac12a1bb2189cdfccf9 100644 (file)
@@ -1,3 +1,7 @@
+2003-01-28  Richard Sandiford  <rsandifo@redhat.com>
+
+       * gcc.c-torture/execute/20030128-1.c: New test.
+
 2003-01-28  Jeffrey D. Oldham  <oldham@codesourcery.com>
 
        * g++.dg/lookup/nested1.C: Test moved from ...
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030128-1.c b/gcc/testsuite/gcc.c-torture/execute/20030128-1.c
new file mode 100644 (file)
index 0000000..ceca322
--- /dev/null
@@ -0,0 +1,10 @@
+unsigned char x = 50;
+volatile short y = -5;
+
+int main ()
+{
+  x /= y;
+  if (x != (unsigned char) -10)
+    abort ();
+  exit (0);
+}