Kraid is a now a real compiler
Kraid: Transitioning to a Fully Functional Compiler
Author: Faith Ekstrand
Date: July 30, 2026
Reading Time: ~4 minutes
The journey of Kraid, the next-generation compiler developed for the Panfrost driver stack, has reached a pivotal turning point. In my previous update, the milestone was modest: we had successfully passed a single Vulkan CTS test.
Today, the progress is staggering. Kraid is now passing one 800,000 Vulkan CTS tests—including several that the legacy compiler actually fails.
⚠️ A Note of Caution
While this is a massive leap, we aren't at the finish line yet. It is important to clarify the current scope of this success:
- Compute Only: The 100% pass rate applies exclusively to compute shaders.
- Pending Implementation: Other shader types are not yet functional, though we anticipate progress in the coming weeks.
- Suboptimal Output: The quality of the generated machine code is currently mediocre.
"The poor code quality is not a flaw in Kraid's architecture, but a deliberate strategic decision. By allowing the register allocator to make suboptimal choices, we can intentionally create high register pressure. This helps us identify and squash bugs in the rest of the compiler that only emerge when resources are tight."
Technical Achievements
We have successfully checked off nearly every requirement on our development roadmap. The current capabilities of Kraid are summarized below:
Core Compiler Features
- Register Allocation: An SSA-based allocator capable of working within a strict, arbitrary fixed budget.
- Spilling Mechanism: An SSA-based spiller that operates in near-linear time—mathematically represented as or —ensuring the program always fits the register limit.
- Data Handling:
- Full support for 64-bit operations.
- Correct implementation of integer and float
widenoperations on sources. - Comprehensive swizzle support across the board.
- Optimization: A copy-propagation pass that handles both word and byte granularity, with the ability to "see through" vector collect operations and swizzles.
- Destination Support: Full 16-bit destination support. Since most hardware instructions lack native 8-bit destinations, Kraid emulates this by utilizing 16 bits.
Hardware Validation
To ensure absolute precision, we don't guess the instruction semantics. Instead, we use a data-driven approach:
| Source | Method | Purpose |
|---|---|---|
| Arm XML | Direct Extraction | Encoding and instruction metadata |
| Hardware Unit Tests | Validation | Verifying precise semantics against actual silicon |
The Road Ahead: Making Kraid "Sing"
Now that the foundation is solid, the focus shifts from functionality to efficiency. We are moving from the "build" phase to the "optimize" phase.
Current Development Pipeline
The Shader Challenge
While vertex shaders are relatively simple to implement, fragment shaders present a steeper challenge due to specific hardware instructions:
BLENDandATEST: These instructions complicate register allocation.- ABI Requirements: Because
BLENDcan act as a function pointer call, we must define a strict Application Binary Interface (ABI) between the primary fragment shader and the blend shader.
This introduces several "edge cases" into the Intermediate Representation (IR) that require further design refinement.
Final Outlook
Despite the remaining work, the potential is clear. Kraid is already outperforming the previous compiler regarding 64-bit arithmetic.
Our Goal Checklist:
- Pass Vulkan CTS (Compute)
- Implement Vertex Shaders
- Implement Fragment Shaders
- Optimize Register Allocation
- Match/Exceed legacy compiler performance across all workloads
While it remains to be seen if Kraid will beat the old compiler in every scenario, the tools are now in place to make that a reality.