☑ MCQ PRACTICE

Compiler Design Unit 5

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

📚 Compiler Design
📖 Unit 5
🎯 MCQs
Compiler Design MCQs - Unit 5

Compiler Design MCQs - Unit 5

1

Evaluating a constant expression at compile time is called

A code motion
B loop unrolling
C inlining
D constant folding
Correct Answer constant folding
2

Dead code is code

A that executes most often
B that is inside a loop
C that has comments
D whose result is never used
Correct Answer whose result is never used
3

Common subexpression elimination

A adds extra computation
B removes all variables
C adds more loops
D avoids recomputing an expression whose value is already available
Correct Answer avoids recomputing an expression whose value is already available
4

Copy propagation replaces uses of x by y after the statement

A x = y + 1
B y = x + x
C x = y
D x = 5
Correct Answer x = y
5

Moving a loop-invariant computation outside the loop is called

A constant folding
B dead-code elimination
C code motion
D copy propagation
Correct Answer code motion
6

Replacing a multiplication in a loop by repeated addition uses

A dead variables
B induction variables (strength reduction)
C global variables only
D labels
Correct Answer induction variables (strength reduction)
7

Data-flow analysis is used to

A scan the input
B generate tokens
C link object files
D collect information about the values at various points in a program
Correct Answer collect information about the values at various points in a program
8

Reaching-definitions analysis is a

A forward data-flow problem
B backward data-flow problem
C lexical problem
D parsing problem
Correct Answer forward data-flow problem
9

Live-variable analysis is a

A forward data-flow problem
B lexical problem
C backward data-flow problem
D linking problem
Correct Answer backward data-flow problem
10

The meet operator for available expressions is

A union
B difference
C intersection
D concatenation
Correct Answer intersection
11

The meet operator for reaching definitions is

A intersection
B union
C difference
D complement
Correct Answer union
12

The data-flow equation for a block B is

A OUT[B] = GEN[B] ∪ (IN[B] − KILL[B])
B OUT[B] = GEN[B] ∩ KILL[B]
C OUT[B] = IN[B] − GEN[B]
D OUT[B] = KILL[B]
Correct Answer OUT[B] = GEN[B] ∪ (IN[B] − KILL[B])
13

A data-flow framework consists of a domain, a direction, a semilattice and

A transfer functions
B tokens
C registers
D labels
Correct Answer transfer functions
14

Constant propagation

A removes all constants
B adds new constants
C replaces a variable by its constant value when the value is known
D renames all variables
Correct Answer replaces a variable by its constant value when the value is known
15

Partial-redundancy elimination removes expressions that are redundant along

A some but not all paths
B no paths
C every path only
D the stack only
Correct Answer some but not all paths
16

A loop in a flow graph has a single entry node called the

A leader
B sentinel
C header
D handle
Correct Answer header
17

A node d dominates a node n if

A d is the last node
B d has no successors
C n is a leaf only
D every path from the entry to n goes through d
Correct Answer every path from the entry to n goes through d
18

A back edge is an edge a → b in which

A b dominates a
B a dominates b only
C a and b are the same node only
D b is a leaf
Correct Answer b dominates a
19

A natural loop is defined by a

A forward edge
B leader
C back edge
D token
Correct Answer back edge
20

A loop-invariant expression is one whose value

A changes in every iteration
B does not change during the execution of the loop
C is always zero
D is stored in the heap
Correct Answer does not change during the execution of the loop
21

Machine-independent optimization is usually applied to

A intermediate code
B the lexical analyzer
C the object file
D the linker script
Correct Answer intermediate code
22

Iterative data-flow algorithms continue until

A the first iteration finishes
B memory is full
C no further change occurs (a fixed point is reached)
D the user stops them
Correct Answer no further change occurs (a fixed point is reached)
23

Loop-invariant code motion improves performance by

A computing invariant expressions once outside the loop
B computing them in every iteration
C removing the loop condition
D adding more branches
Correct Answer computing invariant expressions once outside the loop
24

In available-expressions analysis, an expression is available at a point if it

A is computed on at least one path only
B is never used
C is a constant
D has been computed on every path to that point and not killed since
Correct Answer has been computed on every path to that point and not killed since
25

A flow graph whose loops can all be identified by back edges and dominators is called

A ambiguous
B reducible
C irreducible only
D cyclic only
Correct Answer reducible

Fill in the Blanks

26 Evaluating constant expressions at compile time is called constant ______.
Correct Answer folding
27 Code whose result is never used is called ______ code.
Correct Answer dead
28 Moving a loop-invariant computation out of a loop is called code ______.
Correct Answer motion
29 The meet operator for reaching definitions is ______.
Correct Answer union
30 The meet operator for available expressions is ______.
Correct Answer intersection
31 Live-variable analysis is a ______ data-flow problem.
Correct Answer backward
32 In the equation OUT[B] = GEN[B] ∪ (IN[B] − ______[B]), the missing term is the set of killed definitions.
Correct Answer KILL
33 Iterative data-flow algorithms stop when a ______ point is reached.
Correct Answer fixed
34 Constant propagation replaces a variable by its known constant ______.
Correct Answer value
35 Partial-redundancy elimination removes expressions that are redundant along ______ paths.
Correct Answer some
36 A node d ______ a node n if every path from the entry to n passes through d.
Correct Answer dominates
37 An edge a → b whose head b dominates its tail a is called a ______ edge.
Correct Answer back
38 A back edge defines a ______ loop.
Correct Answer natural
39 The single entry node of a loop is called the loop ______.
Correct Answer header
40 After the statement x = y, copy propagation replaces uses of x by ______.
Correct Answer y
← Back to All MCQs