powi(x, n) is constant folded as if it were pow(x, (double)n) #65088
Labels
constant-folding
Problems related to constant folding in the optimizer
floating-point
Floating-point math
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.
The text was updated successfully, but these errors were encountered: