Skip to content

Inconsistency in sinh(const), cosh(const), and tanh(const) optimizations with -ffast-math #132503

Closed
@k-arrows

Description

@k-arrows

Consider the following test case.
https://godbolt.org/z/Ecd865P97

#include <cmath>

double f1() {
  return std::sinh(0.);
}

double f2() {
  return std::cosh(0.);
}

double f3() {
  return std::tanh(0.);
}

The optimization results for std::sinh(0.), std::cosh(0.), and std::tanh(0.) differ between -O1 and -O1 -ffast-math. Specifically, when -ffast-math is enabled, sinh(0.) and cosh(0.) are not folded into constants but instead call the corresponding library functions. This suggests that -ffast-math is restricting optimization rather than enhancing it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions