http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55760



--- Comment #5 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 
2013-01-08 15:29:18 UTC ---

we just got "hit" by this great type of code (copysign is unknown to

scientists)



most probably gcc could optimize it for -Ofast to return copysignf(1.f,x); (x/x

is optimized in 1)





cat one.cc;c++ -Ofast -mrecip -S one.cc; cat one.s

#include<cmath>

int one(float x) {

  return x/std::abs(x);

}



    .text

    .align 4,0x90

    .globl __Z3onef

__Z3onef:

LFB86:

    movss    LC0(%rip), %xmm2

    andps    %xmm0, %xmm2

    rcpss    %xmm2, %xmm1

    mulss    %xmm1, %xmm2

    mulss    %xmm1, %xmm2

    addss    %xmm1, %xmm1

    subss    %xmm2, %xmm1

    mulss    %xmm0, %xmm1

    cvttss2si    %xmm1, %eax

    ret

Reply via email to