[PATCH, middle-end]: Fix PR 35083

Richard Guenther richard.guenther@gmail.com
Wed Feb 6 10:21:00 GMT 2008


On Feb 6, 2008 11:04 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> This patch fixes soft-float expansion of unsigned integers, where we generate:
>
> test:
>         pushl   %ebp
>         movl    %esp, %ebp
>         subl    $24, %esp
>         movl    8(%ebp), %edx
>         testl   %edx, %edx
>         js      .L3
>         movl    %edx, (%esp)
>         call    __floatsisf
>         leave
>         ret
> .L3:
>         movl    %edx, %eax
>         andl    $1, %eax
>         shrl    %edx
>         orl     %edx, %eax
>         movl    %eax, (%esp)
>         call    __floatsisf
>         movl    %eax, 4(%esp)
>         movl    %eax, (%esp)
>         call    __addsf3
>         leave
>         ret
>
> instead of a simple call to __floatunssisf.
>
> As explained in the PR, we short-circuit can_do_signed by
> !DECIMAL_FLOAT_P (...), and this looks wrong to me. Since generic code
> that selects wider mode for unsigned integers (iff there is signed
> pattern available) works just fine for decimal modes, the solution is
> simply to remove this wrong condition. This fixes soft-fp, where there
> is no floatsisf and floatunssisf pattern present. I have checked that
> DFP still generates expected calls into soft-dfp lib.
>
> 2008-02-06  Uros Bizjak  <ubizjak@gmail.com>
>
>         PR target/35083
>         * optabs.c (expand_float): Do not check for decimal modes when
>         expanding unsigned integer through signed conversion.
>
> Patch was bootstrapped and regression tested on i686-pc-linux-gnu. OK
> for mainline?

This is ok if this is a regression (I suppose it is, if you basically revert to
pre-decimal-float state).

Thanks,
Richard.

> Uros.
>
> Index: optabs.c
> ===================================================================
> --- optabs.c    (revision 132142)
> +++ optabs.c    (working copy)
> @@ -1,6 +1,6 @@
>  /* Expand the basic unary and binary arithmetic operations, for GNU compiler.
>     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
> -   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
> +   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
>     Free Software Foundation, Inc.
>
>  This file is part of GCC.
> @@ -5144,10 +5144,8 @@ expand_float (rtx to, rtx from, int unsi
>        }
>
>    /* Unsigned integer, and no way to convert directly.  Convert as signed,
> -     then unconditionally adjust the result.  For decimal float values we
> -     do this only if we have already determined that a signed conversion
> -     provides sufficient accuracy.  */
> -  if (unsignedp && (can_do_signed || !DECIMAL_FLOAT_MODE_P (GET_MODE (to))))
> +     then unconditionally adjust the result.  */
> +  if (unsignedp && can_do_signed)
>      {
>        rtx label = gen_label_rtx ();
>        rtx temp;
>



More information about the Gcc-patches mailing list