Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andykaylor opened this issue Aug 29, 2023 · 0 comments
Open

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

andykaylor opened this issue Aug 29, 2023 · 0 comments
Labels
constant-folding Problems related to constant folding in the optimizer floating-point Floating-point math

Comments

@andykaylor
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
constant-folding Problems related to constant folding in the optimizer floating-point Floating-point math
Projects
None yet
Development

No branches or pull requests

1 participant