kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit 237cb382308ff6b9e1df5c0fe50c11f67469ad83
parent 53cac58ca3c58f8646a21e1b81c1a0c78eb438a7
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Thu, 28 May 2026 19:12:49 -0700

opt: reduce jump cleanup rescans

Diffstat:
Msrc/opt/pass_jump.c | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/opt/pass_jump.c b/src/opt/pass_jump.c @@ -23,6 +23,16 @@ static u32 next_emit_block(const JumpCleanupCtx* c, u32 block) { return c->f->emit_order[idx + 1u]; } +static void refresh_emit_index_range(JumpCleanupCtx* c, u32 first, u32 last) { + Func* f = c->f; + if (!f || first >= f->emit_order_n) return; + if (last >= f->emit_order_n) last = f->emit_order_n - 1u; + for (u32 i = first; i <= last; ++i) { + u32 b = f->emit_order[i]; + if (b < f->nblocks) c->emit_index_by_block[b] = i; + } +} + static void mark_label_addr_refs(Func* f, u8* refs) { if (!f || !refs) return; for (u32 b = 0; b < f->nblocks; ++b) { @@ -436,11 +446,7 @@ static void cleanup_rotate_loops(JumpCleanupCtx* c) { hterm->extra.imm = inverted; H->succ[0] = body; /* taken: back-edge to the loop body */ H->succ[1] = exit; /* fallthrough: loop exit */ - for (u32 b = 0; b < f->nblocks; ++b) c->emit_index_by_block[b] = BLOCK_NONE; - for (u32 k = 0; k < f->emit_order_n; ++k) { - u32 bb = f->emit_order[k]; - if (bb < f->nblocks) c->emit_index_by_block[bb] = k; - } + refresh_emit_index_range(c, i, latch_pos); } } @@ -573,7 +579,6 @@ void opt_jump_opt(Func* f) { opt_build_cfg(f); c = jump_cleanup_ctx(f); cleanup_invert_jump_fallthrough(&c); - c = jump_cleanup_ctx(f); cleanup_branch_targets(&c); iter_changed |= full_collapse_same_target_branches(f); if (!iter_changed) break;