This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR middle-end/36575


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, &ltwice, &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, &ltwice, &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
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]