Skip to content

powi(x, n) is constant folded as if it were pow(x, (double)n) #65088

Open
@andykaylor

Description

@andykaylor

The LLVM constant folder evaluates llvm.powi.f64(double fC, i32 iC) as if it were pow(double fC, double fC2). This leads to a deviation from the value that would be returned if the expression were not constant folded.

I reproduced it here using C: https://godbolt.org/z/vT4YMYKne

For C maybe you can argue that this doesn't matter because the definition of __builtin_powi says that it makes no guarantees about precision (though I think users expect at least consistency). However, we can't assume that the intrinsic came from the C builtin, so I think this is a problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    constant-foldingProblems related to constant folding in the optimizerfloating-pointFloating-point math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions