From: Jakub Jelinek Date: Tue, 27 Jan 2015 08:26:13 +0000 (+0100) Subject: re PR tree-optimization/64807 (Wrong-code because of wide-int division) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b30ea1387f8e26ad60bd4d71ba2006ea7e11a6ee;p=gcc.git re PR tree-optimization/64807 (Wrong-code because of wide-int division) 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5add60716b0..05b5f74665c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-01-27 Jakub Jelinek + + PR tree-optimization/64807 + * wide-int.cc (wi::divmod_internal): Clear + b_dividend[dividend_blocks_needed]. + 2015-01-26 DJ Delorie * config/rl78/rl78.c (move_elim_pass): Don't optimize away diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 57a58b40a14..f148ca15ed1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-01-27 Jakub Jelinek + 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 index 00000000000..e1bd604be00 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr64807.c @@ -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; +} diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc index 1143b489499..fd7cbb4c384 100644 --- a/gcc/wide-int.cc +++ b/gcc/wide-int.cc @@ -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--;