Created attachment 626 [details]
Enable static alignment on ARM
This code is disabling static alignment, thus vectorization of all fixed-size objects, altogether, on ARM:
// 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
// 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always
// enable alignment, but it can be a cause of problems on some platforms, so we just disable it in
// certain common platform (compiler+architecture combinations) to avoid these problems.
// Only static alignment is really problematic (relies on nonstandard compiler extensions that don't
// work everywhere, for example don't work on GCC/ARM), try to keep heap alignment even
// when we have to disable static alignment.
#if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64)
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
#define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
See how the whitelist of architectures there ^ does not include ARM; the comment above even refers to GCC/ARM issues.
However, this comment doesn't offer any detail on what the affected toolchain versions are, and seems to have been around here for a long time.
Given the attention that ARM has received over the past 5 years, it would be surprising if static alignment were still broken; and few people care about old compilers on ARM - while Android isn't the fastest to upgrade toolchains, it is still the case that hardly anyone seems to use GCC < 4.8 or Clang < 3.5 on Android/ARM at the moment.
On the other hand, vectorization of fixed-size objects is very important for many applications.
So, I would like to just add ARM/ARM64 in the above whitelist of architectures.
I guess that you successfully tested it with such recent compilers. So I'm ok with it, but we could perhaps enable ARM for gcc>=4.8 only to be safe, as we know it will break arm+gccc-old, with old>=4.4 (I don't know for 4.5, 4.6, and 4.7)
Good tip, thanks! I pushed something like this:
Here, all the toolchains we seem to be using seem to pass, but I don't know if that includes any toolchain based on GCC < 4.8. I still enabled alignment on 4.7, because I know it's been used in Android NDK until recently (Android 4.4 I think) and so I would be very surprised if alignment were still broken there, and I suppose some people still care about performance with this toolchain. GCC <= 4.6 remain without static alignment.