Questions: Instruction Selection Techniques

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A compiler backend uses macro expansion: each IR operation maps directly to one fixed machine instruction. The target architecture has a single 'load-and-add' instruction that loads from memory and adds to a register in one cycle. What will the macro expansion backend do?

AAutomatically recognize the opportunity and emit the load-and-add instruction when the pattern appears
BEmit a separate LOAD followed by a separate ADD, missing the opportunity to use the combined instruction
CProduce the same output as tree pattern matching since the semantics are equivalent
DEmit a load-and-add only if the IR was explicitly annotated to request it
Question 2 Multiple Choice

Why does the optimal instruction selection problem become NP-hard in general when the IR is a DAG rather than a tree?

ADAGs have exponentially more nodes than equivalent trees, making pattern enumeration infeasible
BCommon subexpressions share nodes that could be covered by multiple overlapping patterns; choosing the globally optimal assignment is computationally intractable in general
CDynamic programming cannot process directed graphs, eliminating the efficient algorithm available for trees
DMachine instruction sets are too large for the DAG case to enumerate all possible coverings
Question 3 True / False

Optimal tree-tiling instruction selection can be solved in linear time using dynamic programming, but the analogous problem for DAGs is NP-hard in general.

TTrue
FFalse
Question 4 True / False

The goal of instruction selection is to minimize the total number of machine instructions emitted, since fewer instructions usually means faster execution.

TTrue
FFalse
Question 5 Short Answer

What is 'tree tiling' in instruction selection, and why does it produce better code than simple macro expansion?

Think about your answer, then reveal below.