-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Derive(PartialOrd) generates pretty bad code #49505
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
I-slow
Issue: Problems and improvements with respect to performance of generated code.
WG-compiler-performance
Working group: Compiler Performance
WG-llvm
Working group: LLVM backend code generation
Comments
@rust-lang/wg-compiler-performance |
See also #15618, and I guess I should ping @rust-lang/wg-codegen too. |
Not only is it slow, but also wrong; see #49650 |
bors
added a commit
that referenced
this issue
Apr 15, 2018
Fix derive(PartialOrd) and optimise final field operation ```rust // Before (`lt` on 2-field struct) self.f1 < other.f1 || (!(other.f1 < self.f1) && (self.f2 < other.f2 || (!(other.f2 < self.f2) && (false) )) ) // After self.f1 < other.f1 || (!(other.f1 < self.f1) && self.f2 < other.f2 ) // Before (`le` on 2-field struct) self.f1 < other.f1 || (!(other.f1 < self.f1) && (self.f2 < other.f2 || (!(other.f2 < self.f2) && (true) )) ) // After self.f1 < other.f1 || (self.f1 == other.f1 && self.f2 <= other.f2 ) ``` (The big diff is mainly because of a past faulty rustfmt application that I corrected 😒) Fixes #49650 and fixes #49505.
Although this was improved somewhat by #49881, let's keep this open until #49650 (comment) has been addressed (one function call per field comparison). |
bors
added a commit
that referenced
this issue
May 15, 2018
Ensure derive(PartialOrd) is no longer accidentally exponential Previously, two comparison operations would be generated for each field, each of which could delegate to another derived PartialOrd. Now we use ordering and optional chaining to ensure each pair of fields is only compared once, addressing #49650 (comment). Closes #49505. r? @Manishearth (sorry for changing it again so soon!) Close #50755
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
I-slow
Issue: Problems and improvements with respect to performance of generated code.
WG-compiler-performance
Working group: Compiler Performance
WG-llvm
Working group: LLVM backend code generation
Instead of doing stuff such as
(a > b) || !(b > a) && true
inge
, rustc should probably just reuse the operator syntax by doinga >= b
.The text was updated successfully, but these errors were encountered: