re PR tree-optimization/64807 (Wrong-code because of wide-int division)
authorJakub Jelinek <jakub@redhat.com>
Tue, 27 Jan 2015 08:26:13 +0000 (09:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 27 Jan 2015 08:26:13 +0000 (09:26 +0100)
PR tree-optimization/64807
* wide-int.cc (wi::divmod_internal): Clear
b_dividend[dividend_blocks_needed].

* gcc.dg/pr64807.c: New test.

From-SVN: r220153

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr64807.c [new file with mode: 0644]
gcc/wide-int.cc

index 5add60716b072d256fdbf685499b13ccbc89488d..05b5f74665cc925121a3e709dc62c27019320cb2 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/64807
+       * wide-int.cc (wi::divmod_internal): Clear
+       b_dividend[dividend_blocks_needed].
+
 2015-01-26  DJ Delorie  <dj@redhat.com>
 
        * config/rl78/rl78.c (move_elim_pass): Don't optimize away
index 57a58b40a14c6cae304ba642459ebf47aab08bca..f148ca15ed1da3d6ec81ac6af97f0606bcb31948 100644 (file)
@@ -1,5 +1,8 @@
 2015-01-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/64807
+       * gcc.dg/pr64807.c: New test.
+
        PR c/64766
        * gcc.dg/pr64766.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr64807.c b/gcc/testsuite/gcc.dg/pr64807.c
new file mode 100644 (file)
index 0000000..e1bd604
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/64807 */
+/* { dg-do run { target int128 } } */
+/* { dg-options "-O2" } */
+
+__uint128_t
+foo (void)
+{
+  __uint128_t a = -1;
+  __uint128_t b = -1;
+  return a / b;
+}
+
+int
+main ()
+{
+  if (foo () != 1)
+    __builtin_abort ();
+  return 0;
+}
index 1143b48949973d06b45a0b910535b003cc2ef23a..fd7cbb4c3843514d4b81ab2d8d15cf66b6e3c89e 100644 (file)
@@ -1819,6 +1819,7 @@ wi::divmod_internal (HOST_WIDE_INT *quotient, unsigned int *remainder_len,
             divisor_blocks_needed, divisor_prec, sgn);
 
   m = dividend_blocks_needed;
+  b_dividend[m] = 0;
   while (m > 1 && b_dividend[m - 1] == 0)
     m--;