https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106200
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Known to work| |13.1.0 Target Milestone|--- |13.0 Resolution|--- |FIXED --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- In this case, GCC 13 can get rid of the full call to sqrt since GCC knows that dSquared will be positive (or positive inf or a nan) always . advance(double, double, double, double): .LFB1011: .cfi_startproc fmul d2, d2, d2 fmadd d1, d1, d1, d2 fmadd d3, d3, d3, d1 fsqrt d1, d3 fmul d1, d1, d3 fdiv d0, d0, d1 ret LLVM 17 can do the same optimization. A modified testcase: ``` double f(double dSquared, double dt) { double mag = dt / (dSquared * __builtin_sqrt(dSquared)); return mag; } ``` GCC can shrink wrap that starting in GCC 15. so closing as fixed.