Compilers
Which describes a basic block?
- AA run of instructions with no branches in or out midway
- BAll the instructions contained in a single function, gathered together
- CA loop body replicated several times to reduce the number of iterations
Show answer and explanation
Answer: A. A run of instructions with no branches in or out midway
A basic block is an instruction sequence entered only at its first instruction and exited only at its last; once started, execution neither leaves nor enters partway through. Blocks are delimited at branch targets and right after branch instructions. Since execution order within a block is fixed, local optimization is easy, and a control-flow graph with blocks as nodes represents overall flow. A function usually consists of many basic blocks, and replicating a loop body is loop unrolling.
- A. Correct. It is entered only at the start and exited only at the end.
- B. A function usually consists of many basic blocks.
- C. Replicating a loop body is loop unrolling.