Skip to content

Conversation

Copy link

Copilot AI commented Feb 1, 2026

Implementation Plan for Local Value Numbering in ZJIT

Overview

Implement local value numbering (LVN) optimization to eliminate redundant computations within basic blocks. The Effect/AbstractHeap API already exists in the upstream codebase (zjit/src/hir_effect), so we'll use and potentially extend it as needed.

Implementation Checklist

  • Rebase on upstream ruby/ruby master
  • Explore existing Effect/AbstractHeap API
  • Implement local_value_numbering() optimization pass
    • Create InsnKey type for hashing instructions by operation and operands
    • Track pure expressions within each basic block using HashMap
    • Use Union-Find (make_equal_to) to deduplicate redundant computations
    • Leverage existing has_effects() method to identify pure operations
  • Add the pass to the optimize() pipeline
  • Create comprehensive tests for LVN
    • Test deduplication of pure arithmetic operations
    • Test preservation of side-effecting operations
    • Test interaction with constant folding and DCE
  • Run existing tests to ensure no regressions
  • Build and validate implementation

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants