rust/compiler/rustc_mir_dataflow/src
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
..
framework Put Analysis back into Results. 2025-10-28 10:26:50 +11:00
impls Make Analysis immutable in many more places. 2025-10-28 08:23:27 +11:00
move_paths Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
debuginfo.rs mir-opt: Eliminate dead statements even if they are used by debuginfos 2025-10-02 14:58:59 +08:00
drop_flag_effects.rs use let chains in hir, lint, mir 2025-07-28 06:10:14 +05:00
errors.rs Migrate all diagnostics 2022-10-23 10:09:44 +02:00
lib.rs Put Analysis back into Results. 2025-10-28 10:26:50 +11:00
points.rs Reimplement DestinationPropagation according to live ranges. 2025-09-07 16:24:46 +00:00
rustc_peek.rs Eliminate unnecessary dependency from rustc_mir_dataflow to rustc_hir 2025-08-20 15:04:00 -07:00
un_derefer.rs Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
value_analysis.rs Skip process_constant if state has no matching value. 2025-11-16 01:38:16 +00:00