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

AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.