https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116826
Bug ID: 116826 Summary: Optimise log (1.0 / x) into -log (x) Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ktkachov at gcc dot gnu.org Target Milestone: --- float foo (float a) { return __builtin_logf (1.0f / a); } We can avoid the division by folding it into -__builtin_logf (a); under the usual -funsafe-math-optimizations group for all the various standard logs. More generally, log (CST / a) could be folded into log (CST) - log (a).