Files
rust/compiler/rustc_mir_transform/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
..
2025-10-24 02:41:50 +00:00
2025-09-08 15:07:12 -07:00
2025-07-21 08:08:41 +00:00
2025-11-19 00:17:37 -05:00
2025-10-28 10:26:50 +11:00
2025-10-10 12:57:24 +00:00
2025-09-17 21:12:17 +00:00
2025-07-01 19:00:21 +00:00
2025-10-19 02:22:18 +00:00
2025-10-10 12:57:24 +00:00
2025-10-06 10:57:27 -07:00
2025-10-10 12:57:24 +00:00
2025-10-10 12:57:24 +00:00
2025-11-18 00:10:03 +00:00