This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/27364] [4.1/4.2 Regression] VRP miscompiles some unsigned math
- From: "law at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 May 2006 19:44:02 -0000
- Subject: [Bug tree-optimization/27364] [4.1/4.2 Regression] VRP miscompiles some unsigned math
- References: <bug-27364-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #14 from law at redhat dot com 2006-05-02 19:44 -------
Subject: Re: [4.2 Regression] Gcc 4.2
miscompiles binutils
On Sun, 2006-04-30 at 18:21 +0000, pinskia at gcc dot gnu dot org wrote:
>
> ------- Comment #10 from pinskia at gcc dot gnu dot org 2006-04-30 18:21 -------
> Here is the reduced testcase:
> int f(unsigned number_of_digits_to_use)
> {
> if (number_of_digits_to_use >1294)
> return 0;
> return (number_of_digits_to_use * 3321928 / 1000000 + 1) /16;
> }
>
> int main(void)
> {
> if (f(11) != 2)
> __builtin_abort ();
As discussed in the PR, the problem is we don't detect overflow
from MULT_EXPR correctly. This causes us to get an incorrect
range which ultimately cascades into generating the wrong
return value.
This patch fixes the overflow detection for MULT_EXPR. Bootstrapped
and regression tested on i686-pc-linux-gnu, both on the 4.1 branch
and mainline.
------- Comment #15 from law at redhat dot com 2006-05-02 19:44 -------
Created an attachment (id=11362)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11362&action=view)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27364