Code generation and optimisation leave behind chains of unconditional jumps — a branch to a block that only jumps somewhere else, which only jumps somewhere else. Jump threading follows each chain to its final target and rewrites the original branch to go straight there, so control reaches the destination in one hop instead of many. The empty blocks left behind are then dead and swept away.
A branch enters a chain J0→J1→J2→J3→target. Threading rewrites J0 to jump straight to the target and drops the three middlemen. Watch the chain collapse (the same follow-to-root as union-find): live demo
“Jump threading just deletes empty blocks.” — the deeper form threads through conditional branches too: if the path proves a condition’s value, the branch is rewritten to skip straight past the test — a special case of the same follow-the-known-target idea, and a real optimisation, not just cleanup. cited
Following an unconditional jump chain to its terminal — branch-chain elimination — is exactly union-find’s find (dart 048): chase the next-pointer until it stops, compressing the path. Full jump threading goes further, threading through a conditional whose value the incoming edge already determines — not a plain find walk. peephole (McKeeman 1965) / classical
Following the chain to its terminal — the same walk as union-find’s find — runs on the canonical compiler: