Semantic Optimization Pipeline

10 sections

0%
Overview

Make proven facts survive into optimization — including algebraic structure. Ori's compiler already proves rich semantic facts about types, ownership, purity, and structure through the trait system, AIMS lattice, ARC pipeline, and type checker. But too many of these facts are consumed internally and discarded before they can benefit LLVM's optimizer. This plan extends existing infrastructure so that facts the compiler already proves travel one phase farther in the pipeline, and adds algebraic law metadata so that user-defined types (matrix, vector, bignum) receive the same algebraic optimizations that built-in types get today.

Planned

10 sections
Section 1 Not Started

Hygiene & Targeted Fixes

Split bloated files so downstream sections have clean, right-sized modules to extend (BUG-04-029 shift overflow already fixed)

0/56 tasks
Section 2 Not Started

LLVM Metadata Infrastructure

Build the metadata emission layer so Sections 03-04 can attach TBAA, range, and alias metadata to LLVM instructions

0/45 tasks
Section 3 Not Started

AIMS State Export to Codegen

Thread AIMS ownership and uniqueness facts to LLVM codegen so standard LLVM passes benefit from Ori's memory analysis

0/48 tasks
Section 4 Not Started

TBAA, Range, and Invariant Metadata

Emit TBAA on struct field accesses, !range on bounded returns, and !invariant.load on immutable borrowed params

0/46 tasks
Section 5 Not Started

Structural Derive Normalization

Mark derived methods as memory(read) and leave a clean handoff for ARC-level peepholes to Section 09

0/47 tasks
Section 6 Not Started

Runtime Identity Fixes

Fix runtime string and list concat to be true algebraic identities so identity elimination in Section 09 is sound

0/40 tasks
Section 7 Not Started

Algebra Law Schema

Add algebraic law declarations, identity-provider traits, and the exported law/provenance index that Section 09 consumes

0/86 tasks
Section 8 Not Started

Algebra Law Adoption

Install algebraic law declarations on stdlib operator traits and impls so the normalization pass has laws to consume

0/56 tasks
Section 9 Not Started

Algebraic Normalization Pass

Build a step-3b ARC IR normalization pass that rewrites expressions using exported algebraic law metadata

0/90 tasks
Section 10 Not Started

Advanced Rewrites & Verification

Add distributivity with cost model, multiplicative inverse, and comprehensive verification of the full optimization pipeline

0/86 tasks