rust/compiler
bors 8d76d07666 Auto merge of #116012 - cjgillot:gvn-const, r=oli-obk
Implement constant propagation on top of MIR SSA analysis

This implements the idea I proposed in https://github.com/rust-lang/rust/pull/110719#issuecomment-1718324700

Based on https://github.com/rust-lang/rust/pull/109597

The value numbering "GVN" pass formulates each rvalue that appears in MIR with an abstract form (the `Value` enum), and assigns an integer `VnIndex` to each. This abstract form can be used to deduplicate values, reusing an earlier local that holds the same value instead of recomputing. This part is proposed in #109597.

From this abstract representation, we can perform more involved simplifications, for example in https://github.com/rust-lang/rust/pull/111344.

With the abstract representation `Value`, we can also attempt to evaluate each to a constant using the interpreter. This builds a `VnIndex -> OpTy` map. From this map, we can opportunistically replace an operand or a rvalue with a constant if their value has an associated `OpTy`.

The most relevant commit is [Evaluated computed values to constants.](2767c4912e)"

r? `@oli-obk`
2023-12-30 03:45:58 +00:00
..
rustc
rustc_abi
rustc_arena
rustc_ast Introduce const Trait (always-const trait bounds) 2023-12-27 12:51:32 +01:00
rustc_ast_lowering Merge Coroutine lowering functions 2023-12-28 21:24:24 +01:00
rustc_ast_passes Introduce const Trait (always-const trait bounds) 2023-12-27 12:51:32 +01:00
rustc_ast_pretty Auto merge of #119105 - dtolnay:paren, r=WaffleLapkin 2023-12-27 21:27:26 +00:00
rustc_attr Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_baked_icu_data
rustc_borrowck Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_builtin_macros Remove more Session methods that duplicate DiagCtxt methods. 2023-12-24 08:17:47 +11:00
rustc_codegen_cranelift Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_codegen_gcc Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_codegen_llvm Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_codegen_ssa Auto merge of #119258 - compiler-errors:closure-kind, r=eholk 2023-12-26 04:25:53 +00:00
rustc_const_eval Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_data_structures Do not store stable crate id in on-disk hash map. 2023-12-24 17:22:48 +00:00
rustc_driver
rustc_driver_impl Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank 2023-12-26 12:27:29 +00:00
rustc_error_codes rustc_error_codes: Update expected error in E0453.md 2023-12-28 19:46:40 +01:00
rustc_error_messages
rustc_errors Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_expand Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_feature Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb 2023-12-26 13:29:13 -05:00
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #119259 - cjgillot:single-crate-id, r=Mark-Simulacrum 2023-12-29 14:37:40 +00:00
rustc_hir_analysis Fix some comments 2023-12-28 12:23:14 +08:00
rustc_hir_pretty Make closures carry their own ClosureKind, rather than deducing what it is from movability 2023-12-25 16:29:15 +00:00
rustc_hir_typeck Auto merge of #118911 - Young-Flash:fix_issue_118819, r=fmease 2023-12-29 18:39:23 +00:00
rustc_incremental Remove more Session methods that duplicate DiagCtxt methods. 2023-12-24 08:17:47 +11:00
rustc_index
rustc_index_macros
rustc_infer Auto merge of #116012 - cjgillot:gvn-const, r=oli-obk 2023-12-30 03:45:58 +00:00
rustc_interface Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank 2023-12-26 12:27:29 +00:00
rustc_lexer
rustc_lint rustc_lint: Prevent triplication of 'unknown lint' lint 2023-12-28 19:46:51 +01:00
rustc_lint_defs Auto merge of #116274 - RalfJung:soft_unstable, r=cjgillot 2023-12-25 16:26:15 +00:00
rustc_llvm
rustc_log
rustc_macros
rustc_metadata Auto merge of #119259 - cjgillot:single-crate-id, r=Mark-Simulacrum 2023-12-29 14:37:40 +00:00
rustc_middle Auto merge of #119392 - compiler-errors:args-parts, r=Nilstrieb 2023-12-29 04:21:41 +00:00
rustc_mir_build Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_mir_dataflow Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_mir_transform Auto merge of #116012 - cjgillot:gvn-const, r=oli-obk 2023-12-30 03:45:58 +00:00
rustc_monomorphize Remove more Session methods that duplicate DiagCtxt methods. 2023-12-24 08:17:47 +11:00
rustc_next_trait_solver Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_parse Use filter instead of filter_map in Parser::expected_one_of_not_found 2023-12-28 21:19:41 +01:00
rustc_parse_format
rustc_passes Rollup merge of #119402 - est31:fix_if_guard_unused, r=compiler-errors 2023-12-29 11:19:28 +01:00
rustc_pattern_analysis Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_privacy Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_query_impl Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank 2023-12-26 12:27:29 +00:00
rustc_query_system Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, r=compiler-errors 2023-12-26 02:24:39 +00:00
rustc_resolve Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_serialize
rustc_session Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank 2023-12-26 12:27:29 +00:00
rustc_smir Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_span Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb 2023-12-26 13:29:13 -05:00
rustc_symbol_mangling Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_target
rustc_trait_selection Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_traits
rustc_transmute
rustc_ty_utils Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00
rustc_type_ir Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
stable_mir Restore movability to SMIR 2023-12-28 16:35:01 +00:00