-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use transmute_unchecked
in NonZero::new
.
#120809
Use transmute_unchecked
in NonZero::new
.
#120809
Conversation
8c613db
to
d70d320
Compare
cool! |
Thanks! This should save a bunch of MIR. Per https://rust.godbolt.org/z/Ecjsvd9MM, this makes it just fn demo_new(_1: u32) -> f32 {
debug n => _1;
let mut _0: f32;
bb0: {
_0 = _1 as f32 (Transmute);
return;
}
} instead of all this with the pointers fn demo_old(_1: u32) -> f32 {
debug n => _1;
let mut _0: f32;
let mut _2: *const f32;
let mut _3: *const u32;
scope 1 (inlined std::ptr::const_ptr::<impl *const u32>::cast::<f32>) {
debug self => _3;
}
scope 2 (inlined std::ptr::read::<f32>) {
debug src => _2;
let mut _4: *const f32;
scope 3 {
scope 4 (inlined std::ptr::read::runtime::<f32>) {
debug src => _4;
scope 5 (inlined intrinsics::is_aligned_and_not_null::<f32>) {
debug ptr => _4;
scope 6 (inlined std::ptr::const_ptr::<impl *const f32>::is_null) {
debug self => _4;
let mut _5: *const u8;
scope 7 {
scope 8 (inlined std::ptr::const_ptr::<impl *const T>::is_null::runtime_impl) {
debug ptr => _5;
scope 9 (inlined std::ptr::const_ptr::<impl *const u8>::addr) {
debug self => _5;
scope 10 {
scope 11 (inlined std::ptr::const_ptr::<impl *const u8>::cast::<()>) {
debug self => _5;
}
}
}
}
}
}
scope 12 (inlined std::ptr::const_ptr::<impl *const f32>::is_aligned) {
debug self => _4;
scope 13 (inlined align_of::<f32>) {
}
}
}
}
}
}
bb0: {
StorageLive(_2);
StorageLive(_3);
_3 = &raw const _1;
_2 = _3 as *const f32 (PtrToPtr);
StorageDead(_3);
StorageLive(_4);
StorageLive(_5);
_0 = (*_2);
StorageDead(_5);
StorageDead(_4);
StorageDead(_2);
return;
}
} |
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#120308 (core/time: avoid divisions in Duration::new) - rust-lang#120589 (std::thread::available_parallelism merging linux/android/freebsd version) - rust-lang#120596 ([rustdoc] Correctly generate path for non-local items in source code pages) - rust-lang#120672 (std::thread update freebsd stack guard handling.) - rust-lang#120693 (Invert diagnostic lints.) - rust-lang#120704 (A drive-by rewrite of `give_region_a_name()`) - rust-lang#120806 (Clippy subtree update) - rust-lang#120809 (Use `transmute_unchecked` in `NonZero::new`.) - rust-lang#120817 (Fix more `ty::Error` ICEs in MIR passes) r? `@ghost` `@rustbot` modify labels: rollup
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#120308 (core/time: avoid divisions in Duration::new) - rust-lang#120596 ([rustdoc] Correctly generate path for non-local items in source code pages) - rust-lang#120693 (Invert diagnostic lints.) - rust-lang#120704 (A drive-by rewrite of `give_region_a_name()`) - rust-lang#120809 (Use `transmute_unchecked` in `NonZero::new`.) - rust-lang#120817 (Fix more `ty::Error` ICEs in MIR passes) - rust-lang#120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) r? `@ghost` `@rustbot` modify labels: rollup
…ructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#113026 (Introduce `run-make` V2 infrastructure, a `run_make_support` library and port over 2 tests as example) - rust-lang#113671 (Make privacy visitor use types more (instead of HIR)) - rust-lang#120308 (core/time: avoid divisions in Duration::new) - rust-lang#120693 (Invert diagnostic lints.) - rust-lang#120704 (A drive-by rewrite of `give_region_a_name()`) - rust-lang#120809 (Use `transmute_unchecked` in `NonZero::new`.) - rust-lang#120817 (Fix more `ty::Error` ICEs in MIR passes) - rust-lang#120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - rust-lang#120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#113671 (Make privacy visitor use types more (instead of HIR)) - rust-lang#120308 (core/time: avoid divisions in Duration::new) - rust-lang#120693 (Invert diagnostic lints.) - rust-lang#120704 (A drive-by rewrite of `give_region_a_name()`) - rust-lang#120809 (Use `transmute_unchecked` in `NonZero::new`.) - rust-lang#120817 (Fix more `ty::Error` ICEs in MIR passes) - rust-lang#120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - rust-lang#120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120809 - reitermarkus:generic-nonzero-constructors, r=Nilstrieb Use `transmute_unchecked` in `NonZero::new`. Tracking issue: rust-lang#120257 See rust-lang#120521 (comment).
Since the rollup showed perf changes, I'm curious @rust-timer build 1476217 |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (1476217): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 663.818s -> 665.912s (0.32%) |
Seems like the -0.4% here pretty much undid the 0.5% regression, if I'm reading that correctly. |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#113671 (Make privacy visitor use types more (instead of HIR)) - rust-lang#120308 (core/time: avoid divisions in Duration::new) - rust-lang#120693 (Invert diagnostic lints.) - rust-lang#120704 (A drive-by rewrite of `give_region_a_name()`) - rust-lang#120809 (Use `transmute_unchecked` in `NonZero::new`.) - rust-lang#120817 (Fix more `ty::Error` ICEs in MIR passes) - rust-lang#120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - rust-lang#120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#113671 (Make privacy visitor use types more (instead of HIR)) - rust-lang#120308 (core/time: avoid divisions in Duration::new) - rust-lang#120693 (Invert diagnostic lints.) - rust-lang#120704 (A drive-by rewrite of `give_region_a_name()`) - rust-lang#120809 (Use `transmute_unchecked` in `NonZero::new`.) - rust-lang#120817 (Fix more `ty::Error` ICEs in MIR passes) - rust-lang#120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - rust-lang#120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
Tracking issue: #120257
See #120521 (comment).