This is the mail archive of the gcc@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: Omitted conversion float -> double in x86 back-end


Hi Michael,
too late, I've filed the report a few minutes ago.
By the way, if I want to bypass the problem without paying any performance penalty, it is sufficient that I introduce a temporary variable in the C source.
As a matter of fact, this looks to work:


double foo(signed long long l)
{
    double d = (float)l;
    return d;
}

Cheers,
Roberto



Michael Matz wrote:
Hi,

On Tue, 21 Nov 2006, Richard Guenther wrote:

but then regstack comes along and

(insn:TI 10 32 33 2 (set (reg:SF 8 st)
       (float:SF (mem/c/i:DI (plus:SI (reg/f:SI 6 bp)
                   (const_int 8 [0x8])) [3 l+0 S8 A32]))) 172
{*floatdisf2_i387} (nil)
   (nil))

where the *floatdisf2_i387 pattern misses the truncation to SFmode.

(you should file a bugzilla about this)

No you don't need to. This is the usual x87-does-everything-in-extended problem, i.e. PR 323. There is no way to truncate that extended precision to float (or double for that matter) without explicitely storing to memory. If you want to take that performance hit use -ffloat-store, in which case the correct code will be produced:


foo:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $16, %esp
        fildll  8(%ebp)
        fstps   -4(%ebp)
        flds    -4(%ebp)
        fstpl   -16(%ebp)
        fldl    -16(%ebp)
        leave
        ret

Better of course if to use SSE math.


Ciao, Michael.


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