simplify_const_unary_operation (in simplify-rtx.c) does constant propagation for SQRT protected only by: if (HONOR_SNANS (mode) && real_isnan (&d)) return 0; With -frounding-math, it should check whether sqrt was exact and only propagate in that case (sqrt(1)=1, sqrt(.25)=.5, but sqrt(2) should wait for execution). (note that this doesn't happen on a trivial sqrt(2.) example, but I've already seen it happen)
Confirmed. real.c has all the bells and whistles to implement this I think.
Author: jsm28 Date: Thu Nov 21 16:20:28 2013 New Revision: 205223 URL: http://gcc.gnu.org/viewcvs?rev=205223&root=gcc&view=rev Log: PR rtl-optimization/55950 * real.c (real_sqrt): Remove function. * real.h (real_sqrt): Remove prototype. * simplify-rtx.c (simplify_const_unary_operation): Do not fold SQRT using real_sqrt. Modified: trunk/gcc/ChangeLog trunk/gcc/real.c trunk/gcc/real.h trunk/gcc/simplify-rtx.c
Fixed for 4.9 by removing this optimization, in the expectation that any important cases of sqrt constant folding are handled at the GIMPLE level which has proper checks for this.