title: Producing optimised NDK code for multiple architectures?
body: <p>I have some C code for Android that does lots of low-level number crunching. I'd like to know what settings I should use (e.g. for my Android.mk and Application.mk) files so that the code produced will run on all current Android devices but also takes advantage of optimisations for specific chipsets. I'm looking for good default Android.mk and Application.mk settings to use and I want to avoid having to litter my C code with #ifdef branches.</p>
  
  <p>For example, I'm aware that ARMv7 has floating point instructions and some ARMv7 chips support NEON instructions and that the default ARM supports neither of these. Is it possible to set flags so that I can build ARMv7 with NEON, ARMv7 without NEON and the default ARM build? I'm know how to do the latter two but not all 3. I'm cautious about what settings I use as I assume the current defaults are the safest settings and what risks other options have.</p>
  
  <p>For GCC specific optimisation, I'm using the following flags:</p>
  
  <pre><code>LOCAL_CFLAGS=-ffast-math -O3 -funroll-loops
  </code></pre>
  
  <p>I've checked all 3 of these speed up my code. Are there any other common ones I could add?</p>
  
  <p>Another tip I have is to add "LOCAL_ARM_MODE := arm" to Android.mk to enable a speed up on newer arm chips (although I'm confused at exactly what this does and what happens on older chips).</p>