-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[lint request] mul_add #4001
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
I think it's fine for a perf lint to change corner case semantics slightly. If the change is truly undesired, the lint can be allowed and a comment placed as to why the change is not desirable at the given location. |
I would like to make this lint. This seems like a cool first lint to make. |
EthanTheMaster
added a commit
to EthanTheMaster/rust-clippy
that referenced
this issue
Sep 28, 2019
bors
added a commit
that referenced
this issue
Oct 8, 2019
Add suggestion for mul_add Issue #4001: Whenever `a*b+c` is found where `a`,`b`, and `c` are floats, a lint is suggested saying to use `a.mul_add(b, c)`. Using `mul_add` may give a performance boost depending on the target architecture and also has higher numerical accuracy as there is no round off when doing `a*b`. changelog: New lint: `manual_mul_add`
EthanTheMaster
added a commit
to EthanTheMaster/rust-clippy
that referenced
this issue
Oct 8, 2019
Fixed typo Fixes lint name and uses appropriate linting suggestion changed lint help message Added autofixable test Added Autofixable Test Removed Broken Autofixable File updated lints Generated Autofixable/Nonfixable Test Cases Changed Suggestion Applicability
EthanTheMaster
added a commit
to EthanTheMaster/rust-clippy
that referenced
this issue
Oct 8, 2019
Fixed typo Fixes lint name and uses appropriate linting suggestion changed lint help message Added autofixable test Added Autofixable Test Removed Broken Autofixable File updated lints Generated Autofixable/Nonfixable Test Cases Changed Suggestion Applicability Fixed Lint List Count
EthanTheMaster
added a commit
to EthanTheMaster/rust-clippy
that referenced
this issue
Oct 8, 2019
Fixed typo Fixes lint name and uses appropriate linting suggestion changed lint help message Added autofixable test Added Autofixable Test Removed Broken Autofixable File updated lints Generated Autofixable/Nonfixable Test Cases Changed Suggestion Applicability Updated Lint Count
bors
added a commit
that referenced
this issue
Oct 8, 2019
Add suggestion for mul_add Issue #4001: Whenever `a*b+c` is found where `a`,`b`, and `c` are floats, a lint is suggested saying to use `a.mul_add(b, c)`. Using `mul_add` may give a performance boost depending on the target architecture and also has higher numerical accuracy as there is no round off when doing `a*b`. changelog: New lint: `manual_mul_add`
I think this was closed by #4602? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Floating-point code of the form
a * b + c
can be better optimized when written asa.mul_add(b, c)
, but this might change its result because instead of first computinga * b
, rounding that, and then addingc
to it, and rounding that,a.mul_add(b, c)
computesa * b + c
with infinite precision, and only rounds the end result.I think it makes sense to recommend people by default that, if they don't care about their result being computed with higher-precission (and their results changing), they should prefer to use
a.mul_add(b, c)
instead ofa * b + c
(otherwise they can ignore the lint).The text was updated successfully, but these errors were encountered: