Re: Xcode 5.1 compiler option -Ofast
Re: Xcode 5.1 compiler option -Ofast
- Subject: Re: Xcode 5.1 compiler option -Ofast
- From: email@hidden
- Date: Tue, 18 Mar 2014 07:45:23 -0700
On Mon, March 17, 2014 9:16 pm, Chris Lattner wrote:
>
>On Mar 14, 2014, at 11:41 AM, Alex Zavatone <email@hidden> wrote:
>>
>>Just noticed the new compiler option in Xcode 5.1 called Fastest,
Aggressive Optimization.
>>I didn't see any info on this in the What's New in Xcode docs. Is there
>any handy reference for this new feature?
>
>Hi Alex,
>
>This option was new in Xcode 5, it isn't new in 5.1. -Ofast is equivalent
>to turning on -ffast-math (which favors performance over strict IEEE
>numerics) and -fstrict-aliasing as well as increasing code size. One of
>the advanced LLVM talks at WWDC 2013 should have discussed it.
>
>-Chris
According to documentation I could find -Ofast enables the following:
1. All -O3 optimizations
2. -ffast-math
3. The vectorizer (e.g. vectorize loops)
It also looks like strict aliasing has been turned on by default in a
separate switch since Xcode 4.6. I don't see anything that says -Ofast
affects this option, unless it's somehow bound up in -O3. I would be
interested in finding out more info about this if someone has it.
Of course there are some caveats for using -Ofast:
Do not use if your application has high floating point precision
requirements.
-ffast-math breaks IEEE 754 conformance. If you dont know why you need
+/-INF or +/-0 you should be wary. Definitely not appropriate for
scientific/financial calculations that need precision.
Test carefully
A requirement whenever you make changes that involve code-gen. In addition
to unit tests, you should also test with Instruments to make sure
performance actually improves. (see previous comments about cache misses)
In general, Im wary of turning on optimizations just because its easy to
set a switch. You have a greater chance of exposing bugs in your code and
the toolchain, and those bugs are often very hard to track down. But Apple
has been recommending -Ofast a lot so this looks like a good switch to
explore.
Happy optimizing!
Doug Hill
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden