]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
authorbors <bors@rust-lang.org>
Wed, 4 Aug 2021 12:58:31 +0000 (12:58 +0000)
committerbors <bors@rust-lang.org>
Wed, 4 Aug 2021 12:58:31 +0000 (12:58 +0000)
commit7f3dc0464422ebadf3b8647f591bcf6e3107e805
treea59cd1b4392ab4df27811595393a1d1fe523feeb
parent87d713ff2b000e3827ebb8be974b280188fac783
parenta3fb1d618823ccab589fbca2b6d4cc3619900bc1
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se

Make wrapping_neg() use wrapping_sub(), #[inline(always)]

This is a follow-up change to the fix for #75598. It simplifies the implementation of wrapping_neg() for all integer types by just calling 0.wrapping_sub(self) and always inlines it. This leads to much less assembly code being emitted for opt-level≤1 and thus much better performance for debug-compiled code.

Background is [this discussion on the internals forum](https://internals.rust-lang.org/t/why-does-rust-generate-10x-as-much-unoptimized-assembly-as-gcc/14930).
library/core/src/num/int_macros.rs
library/core/src/num/uint_macros.rs