Skip to content

optimize pow(x, i1) / pow(x, i2) with fast-math #67216

@k-arrows

Description

@k-arrows

Consider the following:

#include <cmath>

double f1(double x)
{
    return pow(x, 2) / pow(x, 1);
}

double f2(double x)
{
    return pow(x, 3) / pow(x, 1);
}

https://godbolt.org/z/jjKE5n8o1
If -Ofast is specified, GCC just calculates x * x for f2, but Clang performs floating-point division.

When I lower the version to Clang 14.0.0, it behaves as expected, has anything changed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions