Skip to content

Commit be3ce2f

Browse files
committed
Auto merge of rust-lang#94517 - aDotInTheVoid:inline_wrapping_next_power_two, r=yaahc
Mark `uint::wrapping_next_power_of_two` as `#[inline]` This brings it in line with `next_power_of_two` and `checked_next_power_of_two` https://godbolt.org/z/Tr18GnqKj <details> <summary> Output as of `rustc 1.61.0-nightly (4ce3749 2022-02-28)` </summary> ```asm example::npot: lea eax, [rdi - 1] movzx eax, al lzcnt ecx, eax add ecx, -24 mov al, -1 shr al, cl inc al cmp dil, 2 movzx ecx, al mov eax, 1 cmovae eax, ecx ret example::cnpot: lea eax, [rdi - 1] movzx eax, al lzcnt ecx, eax add ecx, -24 mov al, -1 shr al, cl xor ecx, ecx cmp dil, 2 movzx edx, al cmovb edx, ecx inc dl setne al ret example::wrapping_next_power_of_two: jmp qword ptr [rip + _ZN4core3num20_$LT$impl$u20$u8$GT$26wrapping_next_power_of_two17hd879a85055735264E@GOTPCREL] ``` </details>
2 parents 4a87ae2 + 9d6055b commit be3ce2f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/src/num/uint_macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,7 @@ macro_rules! uint_impl {
22262226
#[doc = concat!("assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4);")]
22272227
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.wrapping_next_power_of_two(), 0);")]
22282228
/// ```
2229+
#[inline]
22292230
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
22302231
reason = "needs decision on wrapping behaviour")]
22312232
#[rustc_const_unstable(feature = "wrapping_next_power_of_two", issue = "32463")]

0 commit comments

Comments
 (0)