title: How do you load/store from/to an array of doubles with GNU C Vector Extensions?
body: <p>I'm using <a href="https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html" rel="nofollow">GNU C Vector Extensions</a>, not Intel's <code>_mm_*</code> intrinsics.</p>
  
  <p>I want to do the same thing as Intel's <code>_m256_loadu_pd</code> intrinsic. Assigning the values one by one is slow: gcc produces code that has 4 load instructions, rather than one single <code>vmovupd</code> (which <code>_m256_loadu_pd</code> does generate).</p>
  
  <pre><code>typedef double vector __attribute__((vector_size(4 * sizeof(double))));
  
  int main(int argc, char **argv) {
      double a[4] = {1.0, 2.0, 3.0, 4.0};
      vector v;
  
      /* I currently do this */
      v[0] = a[0];
      v[1] = a[1];
      v[2] = a[2];
      v[3] = a[3];
  }
  </code></pre>
  
  <p>I want something like this:</p>
  
  <pre><code>v = (vector)(a);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>v = *((vector*)(a));
  </code></pre>
  
  <p>but neither work. The first fails with "can't convert value to a vector" while the second results in segfaults. </p>