https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83351
Bug ID: 83351 Summary: Missed optimization in math expression: sin^2(a) + cos^2(a) == 1 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 a) { return cos(a) * cos(a) + sin(a) * sin(a); } generates this assembly: test(double): sub rsp, 24 mov rsi, rsp lea rdi, [rsp+8] call sincos vmovsd xmm1, QWORD PTR [rsp+8] vmovsd xmm0, QWORD PTR [rsp] add rsp, 24 vmulsd xmm1, xmm1, xmm1 vfmadd132sd xmm0, xmm1, xmm0 ret But there is formula: sin^2(a) + cos^2(a) == 1. And it can be compiled in faster way.