http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55760
Marc Glisse <glisse at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |glisse at gcc dot gnu.org --- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> 2013-01-08 23:55:18 UTC --- (In reply to comment #5) > 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); > } That looks like a completely different issue than this PR, I think you should open a different PR if you don't want it to get lost. It seems easy to add a few lines to fold_binary_loc about it (not the best place, but that's where the others are) near the place that optimizes A / A to 1.0. You could try writing the patch, I don't foresee any trap.