Piotr Wyderski <piotr.wyder...@gmail.com> writes: > I'm implementing in C++ a semi-portable portable bit vector based on > SIMD extensions > available on the platform. GCC automatically vectorizes it to a large > extent, but much > better code could have been generated it there were a way to annotate > the source code somehow. > Namely, in many places I know that a pointer points to an 8-bytes > aligned array of std::uint64_t > (hence the compiler should use movdqu), but the number of elements is > divisible by 2, so no fixup > code needs to be generated and only the SSE2-based variant should be emitted. > > Is there a way to tell the compiler about it via some attribute or > pragma? Of course a full-blown > platform-specific variant of the source code is possible, but as the > vectorizer does a good job > (relatively to its limited knowledge), I would prefer to help it > instead of reimplementing the vector.
If you are asking for help using gcc, then the right mailing list is gcc-h...@gcc.gnu.org. The mailing list gcc@gcc.gnu.org is about the development of gcc itself. If you just want to use gcc, then please take any followups to gcc-help. Thanks. You can use __attribute__ ((aligned)) to set the alignment. However, as far as I know there is no way to indicate anything about the number of elements. I assume from your description that you are passing in the number of elements; perhaps you should pass in half that number and multiply it by 2 in your code. That may give gcc enough information to compile your code as you prefer. Ian