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]

rs6000: floating point cast oddities?


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


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