This is a re-thinking of a question I asked in the Discord: what optimizations happen at MIR? Does constant propagation happen here, or is that job done at the LLVM-IR level only?
There is some constant propagation, IIRC (miri) and there is potential for more.
Nice! Is this documented somewhere? Maybe in RFCs? If you have a keyword I can use to look for PRs at the rustc repo, that would do as well :)
The constant propagation code is in https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/const_prop.rs but it only lints if propagation would fail (aka there'd be a panic at runtime), it doesn't actually propagate right now
It's also very limited, as it doesn't understand
match right now
So if I understood correctly, there's some pieces of the c.p. implemented but it's not propagating anything atm?
Yes, iirc there were performance concerns. We should investigate those.