This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
rs6000: floating point cast oddities?
- From: degger at fhm dot edu
- To: gcc at gcc dot gnu dot org
- Date: Mon, 17 Dec 2001 18:07:22 +0100 (CET)
- Subject: rs6000: floating point cast oddities?
- Reply-to: degger at fhm dot edu
Hija,
Consider:
float
foo (float a, float b)
{
return b+1.0;
}
What I expect it do to is:
Load a single precision 1.0 and add it to the register
of the second parameter.
What I get with current gcc is:
.LC0:
.long 0x3ff00000
.long 0x0
.section ".text"
.align 2
.globl foo
.type foo,@function
foo:
lis 9,.LC0@ha
la 9,.LC0@l(9)
lfd 0,0(9)
fadd 2,2,0
frsp 2,2
fmr 1,2
blr
So it loads a double 1.0, adds it using full precision and then converts
it back to single precision (not without having a superfluous float
register move as mentioned in the other mail).
I can prevent gcc from doing it in double precision by adding a cast but
this is not a good reason for being stupid in the first place I guess.
:)
--
Servus,
Daniel