http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48092
--- Comment #4 from rguenther at suse dot de <rguenther at suse dot de> 2011-09-08 10:50:46 UTC --- On Thu, 8 Sep 2011, vincenzo.innocente at cern dot ch wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48092 > > --- Comment #3 from vincenzo Innocente <vincenzo.innocente at cern dot ch> > 2011-09-08 10:01:48 UTC --- > btw even in C with -Ofast > a*exp(x)*exp(y) (same for sqrt) is NOT optimized. compare > > double exp0(double x, double y) { > return exp(x)*exp(y); > } > > double exp1(double a, double x, double y) { > return a*exp(x)*exp(y); > } Yes, that's because those simplification all are implemented in fold-const.c. Compare double exp03(double a, double x, double y) { double tmp1 = exp(x); double tmp2 = exp(y); return a*(tmp1*tmp2); } and in fold-const.c we don't associate FP math. tree-ssa-reassoc.c re-associates exp1, but then the simplification is missing - see my exp03 example.