I have not yet seen that either GCC or Intel C ++ automatically vectorize anything other than very simple loops, even if the given code is algorithms that can (and were after I manually rewrote them using SSE-intrinsics) will be vectorized.
Part of this is conservative - especially when it comes to possible pointer smoothing, it can be very difficult for the C / C ++ compiler to βproveβ that vectorization will be safe, even if you, as a programmer, know what it is. Most compilers (reasonably) prefer not to optimize the code, but to risk compromising it. This is one area where higher-level languages ββhave a real advantage over C, at least in theory (I speak theoretically since I don't know about any automatic vectorization of ML or Haskell compilers).
Another part of this is just analytical limitations - most of the research in the field of vectorization, I understand, is connected with the optimization of classical numerical problems (for example, fluid dynamics), which was a little bread and butter of most vector machines a few years ago (when, between CUDA / OpenCL , Altivec / SSE and STI cell, vector programming in various forms has become widely available in commercial systems).
It is rather unlikely that code written for the processor in the mind will be easy to vectorize the compiler. Fortunately, many things you can do to make it easier for the compiler to figure out how to vectorize it, such as loop tiles and expanding a partial loop, also (usually) help performance on modern processors, even if the compiler doesn't understand how to vectorize it.
source share