What are the advantages of armv7 over armv6 when compiling iPhone apps?

M. Ryan picture M. Ryan · Jul 22, 2010 · Viewed 44.5k times · Source

If there are any advantages at all... couldn't find anything conclusive in the docs.

Apparently armv7 is for newer version of iOS... is it faster? smaller? Better at X?

Answer

Brad Larson picture Brad Larson · Jul 22, 2010

The older iOS devices (iPhone, iPhone 3G, first and second generation iPod touch) had CPUs that only supported the armv6 instruction set. The iPhone 3G S (and iPad and third-generation iPod touch) has a newer processor that also supports the armv7 instruction set. In general, armv7 is faster on these newer processors and it is recommended that you at least include an armv7 build in your applications going forward (in an iPad-only application, you can probably just build for armv7).

As Jasarien points out, the area of largest difference between the instruction sets is in floating-point operations. On armv6, applications tended to be built using the reduced Thumb instruction set to produce smaller binaries, but Thumb floating-point performance was terrible. Therefore, you needed to disable Thumb is you wanted faster floating-point calculations. On armv7, the Thumb-2 instruction set no longer has this limitation, so Apple recommends you compile using it almost all the time.

You can make the Thumb build setting conditional so that it is off for older devices and on for newer ones. To do this, go to your Xcode build settings and select the Compile for Thumb option. Go to the menu at the bottom-left of the screen and choose the Add Build Setting Condition option. In the new build setting condition, choose ARMv6 for the architecture, turn off Thumb for it, add another condition, choose ARMv7 for its architecture, and enable Thumb for it.

According to Stephen Canon's answer here, both single and double-precision floating-point operations are supported in hardware in armv6. I've found that single-precision arithmetic performs slightly better on this platform, perhaps due to more operations fitting into cache. On armv7, the NEON SIMD floating-point unit only works on single-precision operations, so there can be a vast difference in performance between single and double precision operations.

Other questions that might be of interest on this subject include: