mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-11 01:17:39 +00:00
![]() Don't re-`assume` in `transmute`s that don't change niches I noticed in nightly 2025-02-21 that `transmute` is emitting way more `assume`s than necessary for newtypes. For example, the three transmutes in <https://rust.godbolt.org/z/fW1KaTc4o> emits ```rust define noundef range(i32 1, 0) i32 `@repeatedly_transparent_transmute(i32` noundef range(i32 1, 0) %_1) unnamed_addr { start: %0 = sub i32 %_1, 1 %1 = icmp ule i32 %0, -2 call void `@llvm.assume(i1` %1) %2 = sub i32 %_1, 1 %3 = icmp ule i32 %2, -2 call void `@llvm.assume(i1` %3) %4 = sub i32 %_1, 1 %5 = icmp ule i32 %4, -2 call void `@llvm.assume(i1` %5) %6 = sub i32 %_1, 1 %7 = icmp ule i32 %6, -2 call void `@llvm.assume(i1` %7) %8 = sub i32 %_1, 1 %9 = icmp ule i32 %8, -2 call void `@llvm.assume(i1` %9) %10 = sub i32 %_1, 1 %11 = icmp ule i32 %10, -2 call void `@llvm.assume(i1` %11) ret i32 %_1 } ``` But those are all just newtypes that don't change size or niches, so none of it's needed. After this PR it's down to just ```rust define noundef range(i32 1, 0) i32 `@repeatedly_transparent_transmute(i32` noundef range(i32 1, 0) %_1) unnamed_addr { start: ret i32 %_1 } ``` because none of those `assume`s in the original actually did anything. (Transmuting to something with a difference niche, though, still has the assumes -- the other tests continue to pass checking that.) |
||
---|---|---|
.. | ||
aggregate-thin-pointer.rs | ||
carrying_mul_add.rs | ||
cold_path2.rs | ||
cold_path3.rs | ||
cold_path.rs | ||
compare_bytes.rs | ||
const_eval_select.rs | ||
ctlz.rs | ||
ctpop.rs | ||
disjoint_bitor.rs | ||
exact_div.rs | ||
likely_assert.rs | ||
likely.rs | ||
mask.rs | ||
nontemporal.rs | ||
offset_from.rs | ||
offset.rs | ||
prefetch.rs | ||
ptr_metadata.rs | ||
rotate_left.rs | ||
rustc_intrinsic_must_be_overridden.rs | ||
select_unpredictable.rs | ||
three_way_compare.rs | ||
transmute-niched.rs | ||
transmute-x64.rs | ||
transmute.rs | ||
typed_swap.rs | ||
unchecked_math.rs | ||
unlikely.rs | ||
volatile_order.rs | ||
volatile.rs |