This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Omitted conversion float -> double in x86 back-end
- From: Roberto COSTA <roberto dot costa at st dot com>
- To: GCC mailing list <gcc at gcc dot gnu dot org>
- Date: Tue, 21 Nov 2006 16:13:54 +0100
- Subject: Omitted conversion float -> double in x86 back-end
Hello,
I've just noticed that, in a sequence of conversions signed long long ->
float -> double, x86 back-end eats the intermediate conversion away.
In this case, the conversion to float isn't redundant because it lowers
the precision of the computation (which is something a programmer may
want to do).
It looks to me this this is a bug; I'm not completely sure because of my
ignorance of what C standards state about it.
Before filing a report, I'd like to hear other opinions.
Here is a simple example:
------------- float_conv.c ------------
double foo(signed long long l)
{
return (float)l;
}
---------------------------------------
Files float_conv.c.026t.fixupcfg and float_conv.s are the outcome of the
following compilation:
gcc -O0 float_conv.c -S -fdump-tree-all
------ float_conv.c.026t.fixupcfg -----
;; Function foo (foo)
foo (l)
{
float D.1524;
double D.1523;
<bb 2>:
D.1524 = (float) l;
D.1523 = (double) D.1524;
return D.1523;
}
---------------------------------------
------------- float_conv.s ------------
.file "float_conv.c"
.text
.globl foo
.type foo, @function
foo:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl 8(%ebp), %eax
movl %eax, -8(%ebp)
movl 12(%ebp), %eax
movl %eax, -4(%ebp)
fildll -8(%ebp)
leave
ret
.size foo, .-foo
.ident "GCC: (GNU) 4.2.0 20060826 (experimental)"
.section .note.GNU-stack,"",@progbits
---------------------------------------
The conversion is still there at the end of GIMPLE passes, which leads
me to the conclusion that it is removed in RTL compilation.
Comments?
Cheers,
Roberto