-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Missed optimization in math expression: sqrt(pow(a, 2.0)) == |a| #34949
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
Comments
assigned to @rotateright |
Could be in InstCombine. |
I thought we already had this one via: Let me see how it escaped. |
The fmul lost its 'fast' FMF: define double @test(double) local_unnamed_addr #0 {
%2 = fmul double %0, %0
%3 = tail call fast double @llvm.sqrt.f64(double %2)
ret double %3
} |
See a lot of optimizations here: https://github.com/gcc-mirror/gcc/blob/07b69d3f1cd3dd8ebb0af1fbff95914daee477d2/gcc/match.pd |
Should be fixed after: Note that there's a sibling bug for pow(x, -1.0) that is still alive (I marked it with a 'FIXME' comment in the source). Also, we should be getting these folds with vector types too, but I suspect we're missing a bunch of those cases. |
https://reviews.llvm.org/rL320312 I don't think that's a factor in any of the related bugs so far, but feel free to double-check. Thanks for filing these! |
mentioned in issue #34959 |
Extended Description
clang(trunk) with '--std=c++17 -O3 -march=native -ffast-math' flags for this code:
generates this assembly:
gcc(trunk) with '--std=c++17 -O3 -march=native -ffast-math' flags generates this:
The text was updated successfully, but these errors were encountered: