Machine-translated by Google. Questions are authored in English.
Top

Discussion

State whether the following is true or false.
An optimising compiler always produces the fastest possible target program for a given source.

  • A.True
  • B.False
  • C.True only at large scales
  • D.False only at small scales

Answer: B

Correct answer: False

Optimal code generation is undecidable in general, and the individual subproblems - register allocation and instruction scheduling among them - are NP-hard. Compilers therefore use heuristics that usually improve the program without any guarantee of optimality.

Optimisations also interact: one may block another, and an apparently local improvement can worsen cache or branch behaviour. "Optimising" describes the attempt rather than the outcome, which is why compilers offer several levels rather than one correct answer.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.