Skip to content

Conversation

Copy link

Copilot AI commented Feb 1, 2026

Extends the toy load/store optimizer from https://github.com/tekknolagi/tekknolagi.github.com/blob/main/loadstore.py with Type-Based Alias Analysis to distinguish memory operations on different Ruby object types.

Changes

Core TBAA implementation (loadstore.py)

  • 8 typed allocation operations: alloc_array(), alloc_hash(), alloc_string(), etc.
  • may_alias(obj1, obj2, offset1, offset2): returns false for different types, enabling cross-type optimization
  • optimize_load_store_tbaa(): eliminates loads invalidated only by same-type stores

Key insight: Stores to different object types cannot alias, even at the same offset. This allows load elimination across type boundaries that would otherwise require conservative invalidation.

Example optimization:

array = bb.alloc_array()
hash = bb.alloc_hash()
v1 = bb.load(array, 0)
bb.store(hash, 0, 42)    # Different type - doesn't invalidate array load
v2 = bb.load(array, 0)   # Eliminated, reuses v1

Without TBAA, the hash store would conservatively invalidate the array load.

Documentation

  • LOADSTORE_README.md: Technical details, aliasing rules, limitations
  • QUICKSTART.md: Getting started guide
  • demo_loadstore.py: 6 concrete optimization scenarios

Test coverage: 11 tests covering basic load/store elimination and TBAA-specific scenarios (same type conservative, different types aggressive, unknown types safe).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bernsteinbear.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@tekknolagi
Copy link
Owner

Don't do this in HIR. Just make a small Ruby implementation of a sample IR like the blog post

Copilot AI and others added 5 commits February 1, 2026 20:09
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Co-authored-by: tekknolagi <401167+tekknolagi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add advanced alias classes with TBAA implementation Implement TBAA-based load/store optimization in standalone Python IR Feb 1, 2026
Copilot AI requested a review from tekknolagi February 1, 2026 20:18
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