https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83354
Bug ID: 83354 Summary: Missed optimization in math expression: pow(cbrt(x), y) == pow(x, y / 3) Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zamazan4ik at tut dot by Target Milestone: --- gcc(trunk) with '--std=c++17 -O3 -march=native -ffast-math' flags for this code: #include <cmath> double test(double x, double y) { return pow(cbrt(x),y); } generates this assembly: test(double, double): sub rsp, 24 vmovsd QWORD PTR [rsp+8], xmm1 call cbrt vmovsd xmm1, QWORD PTR [rsp+8] add rsp, 24 jmp __pow_finite As you can see, we can simplify it by calling pow(x, y/3). It should be faster.