Advanced Topics MCQs January 8, 2026December 14, 2024 by u930973931_answers 30 min Score: 0 Attempted: 0/30 Subscribe 1. What is an intermediate representation (IR) in compiler design? (A) The final machine code generated by the compiler (B) The linker output (C) The original source code (D) A data structure or code used internally to represent source code during compilation 2. Which of the following is an example of a low-level IR? (A) Abstract syntax tree (AST) (B) Three-address code (C) Control flow graph (CFG) (D) Bytecode 3. What is register allocation in compiler optimization? (A) Assigning program variables to a limited number of CPU registers (B) Assigning variables to memory locations (C) Allocating memory for the heap (D) Mapping functions to machine code 4. What is the purpose of loop unrolling? (A) To reduce the number of iterations in a loop for performance improvement (B) To increase the number of loops (C) To reduce the size of compiled code (D) To simplify syntax analysis 5. What is code inlining? (A) Minimizing the number of variables (B) Converting source code to IR (C) Replacing a function call with the body of the function to reduce call overhead (D) Rewriting loops as recursion 6. Which of the following is an example of data-flow analysis? (A) Lexical tokenization (B) Syntax checking (C) Live variable analysis (D) Linking libraries 7. What is SSA (Static Single Assignment) form used for? (A) Optimizing memory usage (B) Simplifying code generation by ensuring each variable is assigned exactly once (C) Improving parsing efficiency (D) Register allocation 8. What is peephole optimization? (A) Optimizing the entire program at once (B) Optimizing code by examining and replacing short sequences of instructions with more efficient sequences (C) Reducing the size of the source code (D) Minimizing parsing steps 9. What does loop fusion optimize? (A) Unrolling loops automatically (B) Splitting loops into multiple iterations (C) Combining multiple loops into a single loop to reduce overhead (D) Eliminating unnecessary variables 10. What is the main purpose of interprocedural optimization? (A) Optimizing across function or procedure boundaries for better performance (B) Optimizing code within a single function (C) Parsing function definitions (D) Allocating memory for function calls 11. What is tail-call optimization? (A) Register allocation for recursion (B) Eliminating all loops (C) Replacing recursive calls in tail position with iterative loops to save stack space (D) Inlining tail functions only 12. Which of the following is a global optimization technique? (A) Constant folding (B) Dead code elimination (C) Register allocation (D) All of the above 13. What is instruction scheduling? (A) Parsing instructions (B) Allocating registers (C) Rearranging the order of instructions to avoid pipeline stalls in CPUs (D) Generating intermediate code 14. What is partial evaluation in compilers? (A) Generating optimized machine code (B) Running the program partially at runtime (C) Eliminating dead code (D) Precomputing parts of the program at compile-time when some inputs are known 15. Which of the following optimizations improves memory locality? (A) Tail-call elimination (B) Loop interchange (C) Constant propagation (D) Syntax checking 16. What is profile-guided optimization (PGO)? (A) Optimizing syntax parsing (B) Optimizing code based on execution statistics collected from previous runs (C) Minimizing source code size (D) Generating IR automatically 17. What is the main advantage of JIT (Just-In-Time) compilation? (A) Faster compilation time (B) Eliminates the need for cross-compilers (C) Reduced memory usage (D) Runtime optimizations based on actual program behavior 18. What is escape analysis used for in compilers? (A) Detecting syntax errors (B) Optimizing loops (C) Scheduling instructions (D) Determining if a variable can be allocated on the stack instead of the heap 19. Which of the following is a type of speculative optimization? (A) Lexical analysis (B) Constant propagation (C) Optimizing code based on likely runtime paths and undoing if prediction fails (D) Dead code removal 20. What is common subexpression elimination? (A) Register allocation (B) Eliminating variables (C) Scheduling instructions (D) Avoiding recomputation of expressions whose values are already known 21. What is strength reduction in compiler optimization? (A) Optimizing loops for memory access (B) Replacing expensive operations with cheaper equivalent operations (C) Eliminating tail calls (D) Improving syntax parsing 22. What is loop invariant code motion? (A) Reversing loop iteration order (B) Removing loops completely (C) Inlining loop functions (D) Moving computations that produce the same result in every loop iteration outside the loop 23. What is the role of a control flow graph (CFG)? (A) Generate machine code directly (B) Allocate registers (C) Parse syntax trees (D) Represent the flow of control in a program for analysis and optimization 24. What is the purpose of inline caching in JIT compilers? (A) Eliminating loops (B) Reducing memory usage (C) Speeding up method calls by remembering target addresses based on runtime types (D) Generating IR 25. Which optimization focuses on removing unused code? (A) Constant folding (B) Dead code elimination (C) Peephole optimization (D) Tail-call optimization 26. What is loop tiling used for? (A) Constant propagation (B) Unrolling loops (C) Eliminating recursion (D) Improving cache performance by breaking loops into smaller blocks 27. Which optimization can reduce instruction-level dependencies in loops? (A) Loop unrolling (B) Dead code elimination (C) Constant folding (D) Syntax checking 28. What is the main goal of speculative execution in compilers? (A) To guess program behavior and execute instructions ahead of time to reduce stalls (B) To remove dead code (C) To perform register allocation (D) To generate IR efficiently 29. What is interprocedural constant propagation? (A) Removing unused functions (B) Eliminating constants (C) Propagating constants across function boundaries for optimization (D) Optimizing loops only 30. What is devirtualization in compiler optimization? (A) Optimizing loops (B) Eliminating virtual memory (C) Replacing virtual function calls with direct calls when the target type is known at compile-time (D) Improving register allocation