rust/compiler
bors e9e1bbc7a8 Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkin
Stop turning transmutes into discriminant reads in mir-opt

Partially reverts #109612, as after #109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.

Having this "simplification" meant that similar-looking code actually did somewhat different things.  For example,
```rust
pub unsafe fn demo1(x: std::cmp::Ordering) -> u8 {
    std::mem::transmute(x)
}
pub unsafe fn demo2(x: std::cmp::Ordering) -> i8 {
    std::mem::transmute(x)
}
```
in nightly today is generating <https://rust.godbolt.org/z/dPK58zW18>
```llvm
define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef %x) unnamed_addr #0 {
  %0 = icmp uge i8 %x, -1
  %1 = icmp ule i8 %x, 1
  %2 = or i1 %0, %1
  call void `@llvm.assume(i1` %2)
  ret i8 %x
}

define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef %0) unnamed_addr #0 {
  %x = alloca i8, align 1
  store i8 %0, ptr %x, align 1
  %1 = load i8, ptr %x, align 1, !range !2, !noundef !3
  ret i8 %1
}
```

Which feels too different when the original code is essentially identical.

---

Aside: that example is different *after* optimizations too:
```llvm
define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef returned %x) unnamed_addr #0 {
  %0 = add i8 %x, 1
  %1 = icmp ult i8 %0, 3
  tail call void `@llvm.assume(i1` %1)
  ret i8 %x
}

define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef returned %0) unnamed_addr #1 {
  ret i8 %0
}
```
so turning the `Transmute` into a `Discriminant` was arguably just making things worse, so leaving it alone instead -- and thus having less code in rustc -- seems clearly better.
2023-05-17 18:53:26 +00:00
..
rustc
rustc_abi
rustc_apfloat
rustc_arena
rustc_ast
rustc_ast_lowering
rustc_ast_passes
rustc_ast_pretty
rustc_attr
rustc_baked_icu_data
rustc_borrowck
rustc_builtin_macros Rollup merge of #111649 - Nilstrieb:derive-const-param-ty, r=BoxyUwU 2023-05-17 11:13:57 +05:30
rustc_codegen_cranelift Remove LangItems::require 2023-05-16 19:53:38 +02:00
rustc_codegen_gcc
rustc_codegen_llvm Auto merge of #107707 - calebzulawski:remove-features, r=Amanieu 2023-05-15 18:47:52 +00:00
rustc_codegen_ssa Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb 2023-05-17 11:13:55 +05:30
rustc_const_eval Finish move of query.rs 2023-05-17 01:57:21 +02:00
rustc_data_structures Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb 2023-05-17 11:13:55 +05:30
rustc_driver
rustc_driver_impl
rustc_error_codes
rustc_error_messages
rustc_errors Emits E0599 when meeting MyTrait::missing_method 2023-05-17 16:59:39 +08:00
rustc_expand
rustc_feature fixup version placeholder for cfi_encoding feature 2023-05-15 19:19:13 +03:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkin 2023-05-17 11:13:56 +05:30
rustc_hir_analysis Rollup merge of #111588 - MU001999:diag/improve-e0782, r=fee1-dead 2023-05-17 19:11:55 +05:30
rustc_hir_pretty
rustc_hir_typeck Rollup merge of #111588 - MU001999:diag/improve-e0782, r=fee1-dead 2023-05-17 19:11:55 +05:30
rustc_incremental
rustc_index
rustc_infer Rollup merge of #111602 - tmiasko:erroneous-constant-used, r=oli-obk 2023-05-16 11:39:39 +02:00
rustc_interface Auto merge of #108062 - Zoxc:spec-incr, r=cjgillot 2023-05-16 16:02:53 +00:00
rustc_lexer
rustc_lint Rollup merge of #111572 - kpreid:mdi, r=compiler-errors 2023-05-16 11:39:39 +02:00
rustc_lint_defs
rustc_llvm
rustc_log
rustc_macros
rustc_metadata Rollup merge of #110145 - WaffleLapkin:share_slice_of_bytes, r=Nilstrieb 2023-05-17 11:13:55 +05:30
rustc_middle Rollup merge of #111625 - Zoxc:rustc_middle-query-move, r=cjgillot 2023-05-17 19:11:55 +05:30
rustc_mir_build Erase regions of type in offset_of! 2023-05-16 21:36:42 +00:00
rustc_mir_dataflow Rollup merge of #110930 - b-naber:normalize-elaborate-drops, r=cjgillot 2023-05-17 19:11:53 +05:30
rustc_mir_transform Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkin 2023-05-17 18:53:26 +00:00
rustc_monomorphize Finish move of query.rs 2023-05-17 01:57:21 +02:00
rustc_parse Recover impl<T ?Sized> correctly 2023-05-15 17:14:59 +00:00
rustc_parse_format
rustc_passes
rustc_plugin_impl
rustc_privacy
rustc_query_impl Finish move of query.rs 2023-05-17 01:57:21 +02:00
rustc_query_system
rustc_resolve Rollup merge of #111557 - cjgillot:revert-111020, r=petrochenkov 2023-05-17 19:11:54 +05:30
rustc_serialize
rustc_session Remove MetadataRef type alias 2023-05-16 11:55:47 +00:00
rustc_smir
rustc_span Rollup merge of #111654 - JoJoJet:unsafe-cell-from-mut-lib, r=joshtriplett 2023-05-17 11:13:57 +05:30
rustc_symbol_mangling
rustc_target
rustc_trait_selection Rollup merge of #111533 - clubby789:drop-tracking-error, r=oli-obk 2023-05-16 20:12:16 +02:00
rustc_traits
rustc_transmute
rustc_ty_utils Rollup merge of #111578 - Zoxc:query-macro-move, r=cjgillot 2023-05-15 17:12:46 +02:00
rustc_type_ir