mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
![]() Simplify `PartialOrd` on tuples containing primitives We noticed in https://github.com/rust-lang/rust/pull/133984#issuecomment-2704011800 that currently the tuple comparison code, while it [does optimize down](https://github.com/rust-lang/rust/blob/master/tests/codegen/comparison-operators-2-tuple.rs) today, is kinda huge: <https://rust.godbolt.org/z/xqMoeYbhE> This PR changes the tuple code to go through an overridable "chaining" version of the comparison functions, so that for simple things like `(i16, u16)` and `(f32, f32)` (as seen in the new MIR pre-codegen test) we just directly get the ```rust if lhs.0 == rhs.0 { lhs.0 OP rhs.0 } else { lhs.1 OP rhs.1 } ``` version in MIR, rather than emitting a mess for LLVM to have to clean up. Test added in the first commit, so you can see the MIR diff in the second one. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |