Instruction Selection by Tree Covering
Cover intermediate expressions with target patterns and compare legal alternatives by cost without changing arithmetic semantics.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A pattern can cover several intermediate operations
For integer expression \(a+b c\), one target may provide separate multiply and add instructions, while another has an instruction covering both operations under specific widths and overflow behavior. Represent patterns as tree fragments. For each node and desired result class, combine a pattern’s cost with minimum costs for the uncovered children. This is a dynamic program over tree states.
Shared computation and target restrictions matter
An expression DAG may reuse one child at several parents. Treating each parent as an independent tree can duplicate work, so selecting instructions for general shared graphs requires more care. Instruction constraints such as register classes or immediate ranges can rule out apparently low-cost matches. Strength reduction changes which expressions reach this stage. Superoptimization explores equivalent small instruction sequences beyond fixed local patterns.[1][2]