https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68125
Bug ID: 68125 Summary: std::sqrt prevent use of associative math Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vincenzo.innocente at cern dot ch Target Milestone: --- with -Ofast the code generated differs float rsqrt1(float a, float x, float y) { return a/std::sqrt(x)/std::sqrt(y); } float rsqrt2(float a, float x, float y) { return a/sqrtf(x)/sqrtf(y); } rsqrt1(float, float, float): sqrtss %xmm2, %xmm2 sqrtss %xmm1, %xmm1 mulss %xmm2, %xmm1 divss %xmm1, %xmm0 ret rsqrt2(float, float, float): mulss %xmm1, %xmm2 rsqrtss %xmm2, %xmm1 mulss %xmm1, %xmm2 mulss %xmm1, %xmm2 mulss .LC9(%rip), %xmm1 addss .LC8(%rip), %xmm2 mulss %xmm1, %xmm2 mulss %xmm2, %xmm0 ret