Vectorize a function in clang : <p>I am trying to vectorize the following function with clang according to this <a href="http://llvm.org/docs/Vectorizers.html">clang reference</a>. It takes a vector of byte array and applies a mask according to <a href="https://tools.ietf.org/html/rfc6455#section-5.3">this RFC</a>.</p>

<pre><code>static void apply_mask(vector&lt;uint8_t&gt; &amp;payload, uint8_t (&amp;masking_key)[4]) {
  #pragma clang loop vectorize(enable) interleave(enable)
  for (size_t i = 0; i &lt; payload.size(); i++) {
    payload[i] = payload[i] ^ masking_key[i % 4];
  }
}
</code></pre>

<p>The following flags are passed to clang:</p>

<pre><code>-O3
-Rpass=loop-vectorize
-Rpass-analysis=loop-vectorize
</code></pre>

<p>However, the vectorization fails with the following error:</p>

<pre><code>WebSocket.cpp:5:
WebSocket.h:14:
In file included from boost/asio/io_service.hpp:767:
In file included from boost/asio/impl/io_service.hpp:19:
In file included from boost/asio/detail/service_registry.hpp:143:
In file included from boost/asio/detail/impl/service_registry.ipp:19:
c++/v1/vector:1498:18: remark: loop not vectorized: could not determine number
      of loop iterations [-Rpass-analysis]
    return this-&gt;__begin_[__n];
                 ^
c++/v1/vector:1498:18: error: loop not vectorized: failed explicitly specified
      loop vectorization [-Werror,-Wpass-failed]
</code></pre>

<p><strong>How do I vectorize this for loop?</strong></p>
