-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove negative number check from float sqrt #67879
Conversation
It hasn't been UB to pass negative numbers to sqrt since https://reviews.llvm.org/D28797 which was included in LLVM 5.
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @rkruppe |
This is backed up by the reference, which defers to IEEE-754, which notes that:
|
I am reasonably sure we should merge this, but wow, what a mess this situation turned out to be on closer inspection. There are strange subtleties to what "IEEE compliance" means. During that review and in other related patches, concerns were raised over floating point exceptions caused by sqrt of negative operations. The end result is that e.g. This bothers me: not only does it mean this PR theoretically removes some optimization power (today, the "redundant" check means
So it appears to me that the most consistent and useful interpretation of I think we should follow up with an LLVM bug to get this apparent inconsistency in LLVM addressed. In the mean time, I think we should merge this PR, as the improvement in the variable argument case probably outweighs the small loss of constant folding. cc @nagisa @nikic for a second opinion. |
@rkruppe Agree that this change is fine, and that LLVM is in principle allowed to constant fold these. I think a large part of the reason why that doesn't happen is that constant folding for FP libcalls and intrinsics is largely shared (where the former cannot be folded due to the magic of errno), and that it relies on the host libm (not sure how reliable these tend to be where error cases are concerned). |
Alright. @bors r+ |
📌 Commit a35b423 has been approved by |
Remove negative number check from float sqrt It hasn't been UB to pass negative numbers to sqrt since https://reviews.llvm.org/D28797 which was included in LLVM 5.
Remove negative number check from float sqrt It hasn't been UB to pass negative numbers to sqrt since https://reviews.llvm.org/D28797 which was included in LLVM 5.
Rollup of 5 pull requests Successful merges: - #67818 (rustdoc: Avoid panic when parsing codeblocks for playground links) - #67845 (Also remove const-hack for abs) - #67879 (Remove negative number check from float sqrt) - #67881 (Add backticks to various diagnostics) - #67882 (remove bespoke flock bindings) Failed merges: r? @ghost
It hasn't been UB to pass negative numbers to sqrt since https://reviews.llvm.org/D28797 which was included in LLVM 5.