This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 087fc81
committed
Auto merge of rust-lang#116012 - cjgillot:gvn-const, r=oli-obk
Implement constant propagation on top of MIR SSA analysis
This implements the idea I proposed in rust-lang#110719 (comment)
Based on rust-lang#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 rust-lang#109597.
From this abstract representation, we can perform more involved simplifications, for example in rust-lang#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.](rust-lang@2767c49)"
r? `@oli-obk`File tree
209 files changed
+1090
-1582
lines changed- compiler
- rustc_const_eval/src/const_eval
- rustc_mir_transform/src
- tests
- codegen
- coverage
- incremental
- hashes
- mir-opt
- const_prop
- dataflow-const-prop
- dest-prop
- inline
- pre-codegen
- ui/consts/const-eval
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
209 files changed
+1090
-1582
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
308 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
309 | 313 | | |
310 | 314 | | |
311 | | - | |
| 315 | + | |
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
| |||
0 commit comments