rust/compiler/rustc_mir_transform
bors 4ad239f415 Auto merge of #142821 - cjgillot:jump-threading-single, r=saethlin
Compute jump threading opportunities in a single pass

The current implementation of jump threading walks MIR CFG backwards from each `SwitchInt` terminator. This PR replaces this by a single postorder traversal of MIR. In theory, we could do a full fixpoint dataflow analysis, but this has low returns as we forbid threading through a loop header.

The second commit in this PR modifies the carried state to a lighter data structure. The current implementation uses some kind of `IndexVec<ValueIndex, &[Condition]>`. This is needlessly heavy, as the state rarely ever carries more than a few `Condition`s. The first commit replaces this state with a simpler `&[Condition]`, and puts the corresponding `ValueIndex` inside `Condition`.

The three later commits are perf tweaks.

The sixth commit is the main change. Instead of carrying the goto target inside the condition, we maintain a set of conditions associated with each block, and their consequences in following blocks. Think: if this condition is fulfilled in this block, then that condition is fulfilled in that block. This makes the threading algorithm much easier to implement, without the extra bookkeeping of `ThreadingOpportunity` we had.

Later commits modify that algorithm to shrink the set of duplicated blocks. By propagating fulfilled conditions down the CFG, and trimming costly threads.
2025-12-01 23:44:49 +00:00
..
src Auto merge of #142821 - cjgillot:jump-threading-single, r=saethlin 2025-12-01 23:44:49 +00:00
Cargo.toml Introduce ValueSet. 2025-09-13 17:14:04 +00:00
messages.ftl Handle inline asm in has_ffi_unwind_calls 2025-11-25 16:01:02 +00:00