Compiler optimizations: Within the compilation of a PL/I program, what does “machine-independent optimization” refer to?

Difficulty: Medium

Correct Answer: creation of more optimal intermediate representation independent of target machine.

Explanation:

Introduction / Context:Optimization in compilers occurs both before and after target-specific decisions are made. Machine-independent (target-agnostic) optimizations operate on the intermediate representation (IR) without relying on particular instruction sets, focusing on program semantics to improve efficiency.

Given Data / Assumptions:

  • The compiler has produced an IR after parsing and semantic analysis.
  • We have not yet committed to a specific target CPU's instruction set.
  • Transformations must preserve program meaning.

Concept / Approach:Machine-independent optimizations include constant folding, dead-code elimination, common subexpression elimination, copy propagation, strength reduction (algebraic), loop-invariant code motion, and simple loop unrolling. These improve the IR regardless of the final machine. Later, machine-dependent optimizations tune register allocation, instruction scheduling, and addressing modes for a specific architecture.

Step-by-Step Solution:

Identify the stage: work on IR prior to target selection.List canonical target-agnostic transformations (e.g., CSE, DCE).Recognize that the objective is a more optimal IR, not assembly per se.Select the answer describing optimization independent of the target machine.

Verification / Alternative check:Modern compilers (e.g., LLVM, GCC) maintain extensive mid-level, machine-independent optimization passes that apply across architectures.

Why Other Options Are Wrong:Reductions / syntactic constructs: parsing, not optimization. Uniform symbols: lexical analysis. Macro processor to produce better assembly: macro expansion is orthogonal and often target-specific.

Common Pitfalls:Confusing mid-level IR optimizations with backend (machine-dependent) register allocation and scheduling.

Final Answer:creation of more optimal intermediate representation independent of target machine.

More Questions from Operating Systems Concepts

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion