about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/errors.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-30 03:45:58 +0000
committerbors <bors@rust-lang.org>2023-12-30 03:45:58 +0000
commit8d76d076665f862ec9619f2de68d6d9ca1db4601 (patch)
treee8e677eac08c9779819b5c046d8ee9c1d2b37f68 /compiler/rustc_mir_transform/src/errors.rs
parent03b50195ab61a0dc9fc8de43d1de92769c4e6f23 (diff)
parent6d7f0632ede023c71ebcd03c791166c716273b20 (diff)
downloadrust-8d76d076665f862ec9619f2de68d6d9ca1db4601.tar.gz
rust-8d76d076665f862ec9619f2de68d6d9ca1db4601.zip
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.](https://github.com/rust-lang/rust/commit/2767c4912ea249c2f613a9cedcd6c13ea1237e54)"

r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_mir_transform/src/errors.rs')
0 files changed, 0 insertions, 0 deletions