This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR middle-end/36575
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Eric Botcazou" <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Sep 2008 10:17:28 -0700
- Subject: Re: [PATCH] Fix PR middle-end/36575
- References: <200809261843.54675.ebotcazou@adacore.com>
On Fri, Sep 26, 2008 at 9:43 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> the bug comes from the constant folder returning 2 for ROUND_DIV_EXPR (25, 10)
> whereas the correct answer is 3. Except from div_and_round_double:
>
> case ROUND_DIV_EXPR:
> [...]
>
> /* If (2 * abs (lrem) >= abs (lden)) */
> mul_double ((HOST_WIDE_INT) 2, (HOST_WIDE_INT) 0,
> labs_rem, habs_rem, <wice, &htwice);
>
> if (((unsigned HOST_WIDE_INT) habs_den
> < (unsigned HOST_WIDE_INT) htwice)
> || (((unsigned HOST_WIDE_INT) habs_den
> == (unsigned HOST_WIDE_INT) htwice)
> && (labs_den < ltwice)))
>
>
> The comment and the code don't match since day #1:
>
> 330 rms /* if (2 * abs (lrem) >= abs (lden)) */
> 330 rms mul_double (2, 0, labs_rem, habs_rem, <wice, &htwice);
> 330 rms if (((unsigned) habs_den < (unsigned) htwice)
> 330 rms || (((unsigned) habs_den == (unsigned) htwice)
> 330 rms && ((unsigned) labs_den < (unsigned) ltwice)))
>
>
> Obvious fix attached, tested on i586-suse-linux, where should I put it?
Doh. On all active branches.
Thanks,
Richard.
>
> 2008-09-26 Eric Botcazou <ebotcazou@adacore.com>
>
> PR middle-end/36575
> * fold-const (div_and_round_double) <ROUND_DIV_EXPR>: Fix typo.
>
>
> 2008-09-26 Eric Botcazou <ebotcazou@adacore.com>
>
> * gnat.dg/conv_decimal.adb: New test.
>
>
> --
> Eric Botcazou
>