rust/compiler/rustc_codegen_ssa/src/mir
bors 446649d463 Auto merge of #137513 - scottmcm:identity-transmute, r=saethlin
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.)
2025-03-09 01:25:48 +00:00
..
analyze.rs rename BitSet to DenseBitSet 2025-01-11 11:34:01 +00:00
block.rs Use trunc nuw+br for 0/1 branches even in optimized builds 2025-03-06 22:25:49 -08:00
constant.rs introduce ty::Value 2025-01-30 17:47:44 +01:00
coverageinfo.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
debuginfo.rs When LLVM's location discriminator value limit is exceeded, emit locations with dummy spans instead of dropping them entirely 2025-01-19 07:17:33 -08:00
intrinsic.rs Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr 2025-02-10 12:49:18 +00:00
locals.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
mod.rs Rollup merge of #136610 - Jarcho:range_idx, r=Noratrieb 2025-02-24 02:11:32 -05:00
naked_asm.rs rename BackendRepr::Vector → SimdVector 2025-02-28 17:17:45 +01:00
operand.rs Rollup merge of #137894 - compiler-errors:no-scalar-pair-opt, r=oli-obk 2025-03-03 20:47:12 +01:00
place.rs Rollup merge of #137549 - oli-obk:llvm-ffi, r=davidtwco 2025-03-07 19:15:34 +01:00
rvalue.rs Auto merge of #137513 - scottmcm:identity-transmute, r=saethlin 2025-03-09 01:25:48 +00:00
statement.rs reduce false positives of tail-expr-drop-order from consumed values 2024-11-20 20:53:11 +08:00