Back to the 2023 paper

Module 4: Intermediate Code Generation, Code Improvement (optimization)

20232m

The method which merges the bodies of two loops is
(i) Loop rolling
(ii) Loop Jamming
(iii) Constant folding
(iv) None of the above

Worked SolutionAI Assisted

Answer: (ii) Loop Jamming (loop jamming)

Explanation

  • Loop jamming / loop fusion (jamming) is the compiler optimization that merges the bodies of two adjacent loops that have the same range of traversal, into a single loop, so the loop control overhead runs only once.
  • Loop rolling is not a standard optimization.
  • Constant folding folds expressions with only constants at compile time, evaluating them at compile time (e.g. x = 3+4 → x = 7), unrelated to merging loops.
  • "None of the above" is therefore wrong.

Hence the method which merges the bodies of two loops is:

(ii)Loop jamming (loop fusion)\boxed{\text{(ii)Loop jamming (loop fusion)}}

Similar questions

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.