Mike D
Mike D

Reputation: 4946

XCode, LLVM, and Code Optimization - Fastest,Smallest vs None

There some very good descriptions on SO, as well as all over the web, about how LLVM optimizes code. But these fail to answer my specific question.

In Xcode, there are various options for code optimization in the project and target settings. I understand the need for no optimization during development, but why would one choose anything other than Fastest,Smallest[-Os] when compiling a release build.

Upvotes: 4

Views: 2369

Answers (1)

Catfish_Man
Catfish_Man

Reputation: 41801

In most situations, -Os is a good choice. It has a nice mix of optimizing for space and optimizing for speed.

However, the other options do have some appeal:

  • -O/-O1: "I'd like to have a little more ability to debug optimized code"
  • -O2: (ok, honestly not sure why one would choose -O2 over -Os. Maybe if a particular code size optimization -Os does was hurting performance too much?)
  • -O3: "This part of the code needs to be fast, and responds well enough to aggressive inlining and loop unrolling to offset the code size penalty"

Upvotes: 4

Related Questions