https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68743
--- Comment #21 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Tue, Dec 15, 2015 at 08:58:23PM +0000, danglin at gcc dot gnu.org wrote: > > The -fno-builtin option works and gives the best code: > > stw %r2,-20(%r30) > ldo 64(%r30),%r30 > .CALL ARGW0=FR,ARGW1=FU > bl floor,%r2 > fcnvff,sgl,dbl %fr4L,%fr5 > fcnvff,dbl,sgl %fr4,%fr4L > ldw -84(%r30),%r2 > bv %r0(%r2) > ldo -64(%r30),%r30 -fno-builtin would apply to the whole file, and may then be a pessimization for other functions in c99_functions.c. > The first approach in #16 can be made to work but one needs to assign > x to a volatile double instead of retval. The code isn't too bad but > it introduces an unnecessary store/load pair: > > float > floorf (float x) > { > volatile double y = x; > return (float) floor(y); > } > > gives > > stw %r2,-20(%r30) > fcnvff,sgl,dbl %fr4L,%fr4 > ldo 64(%r30),%r30 > ldo -64(%r30),%r28 > fstds %fr4,8(%r28) > fldds 8(%r28),%fr5 > .CALL ARGW0=FR,ARGW1=FU > bl floor,%r2 > nop > I suspect that this is the option that should be committed. It fixes the problem and localizes the store/load penalty to only floorf. If you want to commit the above fix, it's ok with me.