Optimization techniques (local, global, loop optimization)(MCQs)

Local Optimization Techniques What does “local optimization” typically refer to? A) Optimizing the entire program as a whole B) Optimizing specific regions or functions within a program C) Enhancing hardware performance D) Managing operating system resources Answer: B) Optimizing specific regions or functions within a program Which optimization technique is used to remove unnecessary computations within a function? A) Dead code elimination B) Loop unrolling C) Constant propagation D) Function inlining Answer: A) Dead code elimination What is “constant folding” in the context of local optimization? A) Evaluating constant expressions at compile time B) Removing all constants from the code C) Increasing the number of constants in a program D) Converting constants into variables Answer: A) Evaluating constant expressions at compile time What does “common subexpression elimination” achieve? A) Replacing duplicate expressions with a single computation B) Adding more duplicate expressions to the code C) Removing all expressions from the code D) Converting expressions into function calls Answer: A) Replacing duplicate expressions with a single computation What is “strength reduction” used for in local optimization? A) Replacing expensive operations with less expensive ones B) Increasing the number of operations in the code C) Adding more complex operations D) Converting operations into function calls Answer: A) Replacing expensive operations with less expensive ones Which optimization technique is used to replace a function call with its inline code? A) Function inlining B) Dead code elimination C) Loop unrolling D) Constant folding Answer: A) Function inlining What is “peephole optimization”? A) Optimizing small sequences of instructions to improve performance B) Removing all sequences of instructions C) Increasing the number of instructions in the code D) Adding more complex instructions Answer: A) Optimizing small sequences of instructions to improve performance What does “loop invariant code motion” involve? A) Moving computations that do not change within a loop outside of the loop B) Increasing the number of computations within the loop C) Converting loops into conditionals D) Adding more loop variables Answer: A) Moving computations that do not change within a loop outside of the loop Which technique is used to minimize the number of function calls by combining them? A) Function inlining B) Loop unrolling C) Dead code elimination D) Constant propagation Answer: A) Function inlining What is the purpose of “register allocation” in local optimization? A) To assign variables to CPU registers for faster access B) To increase the number of variables in the code C) To manage stack space for function calls D) To optimize loop performance Answer: A) To assign variables to CPU registers for faster access Global Optimization Techniques What is “global optimization” primarily concerned with? A) Optimizing across the entire program or module B) Optimizing individual functions only C) Enhancing hardware performance D) Managing operating system resources Answer: A) Optimizing across the entire program or module What is “interprocedural optimization”? A) Optimizing code across function boundaries to improve overall performance B) Optimizing within a single function only C) Increasing the number of function calls D) Simplifying function parameters Answer: A) Optimizing code across function boundaries to improve overall performance Which optimization technique involves analyzing and optimizing code paths that are executed most frequently? A) Hot path optimization B) Dead code elimination C) Constant folding D) Loop unrolling Answer: A) Hot path optimization What does “profile-guided optimization” involve? A) Using runtime profiling information to guide optimizations B) Adding more function calls C) Simplifying control flow constructs D) Converting all code to machine code Answer: A) Using runtime profiling information to guide optimizations What is the purpose of “data flow analysis” in global optimization? A) To track how data moves through the program and optimize its usage B) To manage function call parameters C) To handle recursion D) To increase the number of function calls Answer: A) To track how data moves through the program and optimize its usage What is “global common subexpression elimination”? A) Replacing duplicate expressions across the entire program with a single computation B) Adding more duplicate expressions to the code C) Removing all expressions from the code D) Converting expressions into function calls Answer: A) Replacing duplicate expressions across the entire program with a single computation What does “global register allocation” involve? A) Allocating CPU registers for variables across multiple functions or the entire program B) Allocating memory for function calls C) Increasing the number of function parameters D) Converting registers into memory variables Answer: A) Allocating CPU registers for variables across multiple functions or the entire program What is “loop fusion”? A) Combining multiple loops with the same iteration space into a single loop B) Splitting a loop into smaller loops C) Converting loops into conditionals D) Adding more loops to the code Answer: A) Combining multiple loops with the same iteration space into a single loop Which technique involves moving computations out of loops or conditionals to avoid redundant execution? A) Code motion B) Loop unrolling C) Constant folding D) Function inlining Answer: A) Code motion What is “loop interchange”? A) Swapping the order of nested loops to improve performance B) Increasing the number of iterations in a loop C) Converting loops into conditionals D) Adding more loop control variables Answer: A) Swapping the order of nested loops to improve performance Loop Optimization Techniques What does “loop unrolling” aim to achieve? A) To reduce the number of loop control instructions and increase performance B) To increase the number of loop iterations C) To convert loops into recursive functions D) To add more loop variables Answer: A) To reduce the number of loop control instructions and increase performance Which optimization technique involves combining multiple loops with the same iteration space into a single loop? A) Loop fusion B) Loop splitting C) Loop interchange D) Loop unrolling Answer: A) Loop fusion What is the purpose of “loop peeling”? A) Separating a few iterations of a loop to simplify its body B) Increasing the number of iterations in a loop C) Converting loops into conditionals D) Adding additional loop control variables Answer: A) Separating a few iterations of a loop to simplify its body What does “loop splitting” involve? A) Dividing a loop into multiple smaller loops to improve performance B) Increasing the number of iterations in a loop C) Converting loops into conditionals D) Adding more loop control variables Answer: A) Dividing a loop into multiple smaller loops to improve performance What technique is used to reduce the number of computations by performing them outside of a loop? A) Loop invariant code motion B) Loop unrolling C) Constant folding D) Function inlining Answer: A) Loop invariant code motion Which technique aims to improve cache performance by optimizing loop data access patterns? A) Cache blocking B) Loop unrolling C) Function inlining D) Dead code elimination Answer: A) Cache blocking What is “loop interchange”? A) Changing the nesting order of loops to optimize performance B) Increasing the number of loop iterations C) Converting loops into conditionals D) Adding more loop variables Answer: A) Changing the nesting order of loops to optimize performance What is “loop fusion” in the context of optimization? A) Combining multiple loops that operate on the same data into a single loop B) Splitting a loop into smaller loops C) Converting loops into conditionals D) Increasing the number of loop iterations Answer: A) Combining multiple loops that operate on the same data into a single loop What technique aims to reduce the loop overhead by executing multiple loop iterations in parallel? A) Loop unrolling B) Loop fusion C) Loop splitting D) Loop interchange Answer: A) Loop unrolling What does “loop unrolling” help to achieve? A) Reducing the overhead of loop control instructions B) Increasing the number of iterations in a loop C) Converting loops into conditionals D) Adding more loop control variables Answer: A) Reducing the overhead of loop control instructions Miscellaneous What is “redundant computation elimination”? A) Removing repeated computations that yield the same result B) Increasing the number of redundant computations C) Converting computations into function calls D) Adding more computations to the code Answer: A) Removing repeated computations that yield the same result What is the primary goal of “instruction scheduling”? A) To arrange instructions to minimize pipeline stalls and maximize parallelism B) To add more instructions to the code C) To convert instructions into function calls D) To increase the number of conditional branches Answer: A) To arrange instructions to minimize pipeline stalls and maximize parallelism What does “data flow analysis” help to optimize? A) The flow and usage of data within a program B) The number of variables in a program C) Memory allocation for data structures D) The number of function calls Answer: A) The flow and usage of data within a program What technique is used to ensure that computations are performed only when necessary? A) Redundant computation elimination B) Loop unrolling C) Function inlining D) Constant folding Answer: A) Redundant computation elimination What is the purpose of “branch prediction” in optimization? A) To guess the outcome of a branch instruction to minimize delays B) To increase the number of branches in the code C) To remove all branch instructions D) To convert branches into loops Answer: A) To guess the outcome of a branch instruction to minimize delays What is “constant folding”? A) Evaluating constant expressions at compile time to improve performance B) Increasing the number of constants in the code C) Removing all constants from the code D) Converting constants into variables Answer: A) Evaluating constant expressions at compile time to improve performance Which optimization technique focuses on improving the execution of frequently executed code paths? A) Hot path optimization B) Dead code elimination C) Function inlining D) Loop unrolling Answer: A) Hot path optimization What does “loop peeling” aim to achieve? A) Simplifying the loop body by handling the first few iterations separately B) Increasing the number of iterations in a loop C) Converting loops into conditionals D) Adding more loop control variables Answer: A) Simplifying the loop body by handling the first few iterations separately Which technique is used to reduce the overhead of function calls by embedding function code directly in place? A) Function inlining B) Dead code elimination C) Loop unrolling D) Constant propagation Answer: A) Function inlining What is “instruction fusion”? A) Combining multiple instructions into a single instruction for improved performance B) Adding more instructions to the code C) Removing all instructions D) Converting instructions into function calls Answer: A) Combining multiple instructions into a single instruction for improved performance What is the goal of “data layout optimization”? A) To arrange data structures in memory to improve access patterns B) To increase the number of data structures in the code C) To remove data structures from the code D) To convert data structures into functions Answer: A) To arrange data structures in memory to improve access patterns What does “loop interchange” optimize? A) The order of nested loops to improve cache performance and data locality B) The number of iterations in a loop C) The conversion of loops into conditionals D) The addition of more loop control variables Answer: A) The order of nested loops to improve cache performance and data locality What is “dead code elimination” used for? A) Removing code that does not affect the program’s output B) Increasing the number of code paths C) Converting dead code into active code D) Adding more code to handle edge cases Answer: A) Removing code that does not affect the program’s output Which technique is used to reduce the number of memory accesses by reusing values stored in registers? A) Register allocation B) Loop unrolling C) Dead code elimination D) Constant folding Answer: A) Register allocation What is the purpose of “loop fusion”? A) Combining multiple loops into a single loop to reduce overhead and improve performance B) Splitting a loop into smaller loops C) Converting loops into conditionals D) Adding more loop control variables Answer: A) Combining multiple loops into a single loop to reduce overhead and improve performance What does “cache blocking” optimize? A) Data access patterns to improve cache performance B) The number of cache blocks C) The size of cache memory D) The conversion of cache to main memory Answer: A) Data access patterns to improve cache performance What is “profile-guided optimization”? A) Using profiling data to guide optimization decisions B) Adding more function calls to the code C) Simplifying control flow D) Converting code into assembly language Answer: A) Using profiling data to guide optimization decisions What is “loop invariant code motion”? A) Moving computations that are invariant across loop iterations outside of the loop B) Increasing the number of loop computations C) Converting loops into conditionals D) Adding more loop control variables Answer: A) Moving computations that are invariant across loop iterations outside of the loop What does “instruction scheduling” aim to achieve? A) Arranging instructions to minimize pipeline stalls and maximize parallelism B) Increasing the number of instructions C) Converting instructions into function calls D) Adding more conditional branches Answer: A) Arranging instructions to minimize pipeline stalls and maximize parallelism What is “redundant computation elimination”? A) Removing repeated computations that yield the same result B) Adding more computations to the code C) Converting computations into function calls D) Increasing the number of redundant computations Answer: A) Removing repeated computations that yield the same result
All Copyrights Reserved 2025 Reserved by T4Tutorials