2 unstable releases

new 0.4.0 Jan 14, 2025
0.3.0 Oct 28, 2024

#808 in Algorithms

Download history 154/week @ 2024-10-24 81/week @ 2024-10-31 32/week @ 2024-11-07 24/week @ 2024-11-14 27/week @ 2024-11-21 17/week @ 2024-11-28 31/week @ 2024-12-05 34/week @ 2024-12-12 8/week @ 2024-12-19 2/week @ 2024-12-26 8/week @ 2025-01-02 139/week @ 2025-01-09

161 downloads per month
Used in 6 crates (via cubecl-spirv)

MIT/Apache

1MB
20K SLoC

Compiler Optimizations

WIP


lib.rs:

CubeCL Optimizer

A library that parses CubeCL IR into a control flow graph, transforms it to static single-assignment form and runs various optimizations on it. The order of operations is as follows:

  1. Parse root scope recursively into a control flow graph
  2. Run optimizations that must be done before SSA transformation
  3. Analyze variable liveness
  4. Transform the graph to pruned SSA form
  5. Run post-SSA optimizations and analyses in a loop until no more improvements are found
  6. Speed

The output is represented as a petgraph graph of BasicBlocks terminated by ControlFlow. This can then be compiled into actual executable code by walking the graph and generating all phi nodes, instructions and branches.

Representing PhiInstruction in non-SSA languages

Phi instructions can be simulated by generating a mutable variable for each phi, then assigning value to it in each relevant block.

Dependencies

~7–21MB
~236K SLoC