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

IphoneObjective CIosXcodeArmv7

Iphone Problem Overview


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?

Iphone Solutions


Solution 1 - Iphone

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:

Solution 2 - Iphone

One of the bigger differences is that the armv6 architecture has hardware support for double precision floating point arithmetic, while armv7 only provides legacy software support for double precision floating point arithmetic.

To compensate, the armv7 architecture has a "NEON" unit that provides blindingly fast hardware support for single precision floating point arithmetic.

This is something you'll need to take into account if you're doing anything that involves floating point arithmetic, whether you're doing it in single or double precision. If you're doing it in double precision, but don't necessarily need that amount of precision, you can probably get a significant performance boost on armv7 devices by using single precision instead.

Apple covered a lot of the differences between armv6 and armv7 and an introduction to the Accelerate framework in one of their WWDC sessions this year. The videos should still be available on iTunes ( as of July '10).

Solution 3 - Iphone

To me, the main advantages of ARMv7 are:

  • thumb-2
  • NEON

NEON must be explicitly coded for, you don't take advantage of it by simply recompiling, but if you can invest the time it can accelerate multimedia/gaming operations by a factor of 8. However thumb-2 is pretty much a free reduction in code size with almost no drawback (contrary to thumb on ARMv6, which makes floating-point code much slower compared to ARM mode). Of course, adding another version of your executable in ARMv7 will not reduce your executable size, but it will reduce your code in memory, caches, etc.

Solution 4 - Iphone

You must compile for both if you want your app to run on iPad and all iPhone/iPod toch models. Older iOS devices use arm6 and new ones use arm7.

The only reason to not compile for one or the other would be reduced app size since it only needs one compiled version of the code. But unless you have a seriously large codebase, this file size difference will be pretty marginal.

Solution 5 - Iphone

arm7 is more optimized for the iPod Touch (3rd Gen) and iPhone 3GS and newer. You need to use 'Standard/arm6+arm7' when building for older devices. In practice, I haven't seen much performance difference in my applications.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionM. RyanView Question on Stackoverflow
Solution 1 - IphoneBrad LarsonView Answer on Stackoverflow
Solution 2 - IphoneJasarienView Answer on Stackoverflow
Solution 3 - IphonePierre LebeaupinView Answer on Stackoverflow
Solution 4 - IphoneAlex WayneView Answer on Stackoverflow
Solution 5 - IphoneAlex ArgoView Answer on Stackoverflow