Language: C++

#include <immintrin.h>
#include <cstdio>

int N;
int a[200000] __attribute__((aligned(64)));
int b[200000] __attribute__((aligned(64)));

int extract(__m128i ret) {
  __m128i t0 = _mm_shuffle_epi32(ret, 176); // [2,3,0,0]
  __m128i t1 = _mm_xor_si128(ret, t0); // [0^2,1^3,x,x]
  __m128i t2 = _mm_shuffle_epi32(t1, 64); // [1^3,x,x,x]
  __m128i t3 = _mm_xor_si128(t1, t2); // [0^2^1^3,x,x,x]
  int rl = _mm_extract_epi16(t3, 6);
  int rh = _mm_extract_epi16(t3, 7);
  return rl + (rh << 16);
}

int extract256(__m256 r) {
  __m128 l = _mm256_extractf128_ps(r, 0);
  __m128 h = _mm256_extractf128_ps(r, 1);
  return extract(l) ^ extract(h);
}

int solve() {
  __m256 r = _mm256_setzero_ps();
  __m128i rh = _mm_setzero_si128();
  for(int i=0;i<N;i+=8) {
    __m128i a0 = _mm_set_epi32(a[i], a[i], a[i], a[i]); // load. latency, througput unknown
    __m128i a1 = _mm_set_epi32(a[i+1], a[i+1], a[i+1], a[i+1]); 
    __m128i a2 = _mm_set_epi32(a[i+2], a[i+2], a[i+2], a[i+2]); 
    __m128i a3 = _mm_set_epi32(a[i+3], a[i+3], a[i+3], a[i+3]);
    __m128i a4 = _mm_set_epi32(a[i+4], a[i+4], a[i+4], a[i+4]); 
    __m128i a5 = _mm_set_epi32(a[i+5], a[i+5], a[i+5], a[i+5]);
    __m128i a6 = _mm_set_epi32(a[i+6], a[i+6], a[i+6], a[i+6]); 
    __m128i a7 = _mm_set_epi32(a[i+7], a[i+7], a[i+7], a[i+7]);
    
    // j+=8 -> 16 no effect..
    for(int j=0;j<N;j+=16) {
      __m256i b0 = _mm256_load_si256((__m256i* const)(&b[j])); // 1l/0.5t
      __m128i b0l = _mm256_extractf128_si256(b0, 0); // 3l/1t
      __m128i b0h = _mm256_extractf128_si256(b0, 1); // 3l/1t

      __m256i b1 = _mm256_load_si256((__m256i* const)(&b[j+8])); // 1l/0.5t
      __m128i b1l = _mm256_extractf128_si256(b1, 0); // 3l/1t
      __m128i b1h = _mm256_extractf128_si256(b1, 1); // 3l/1t

      __m128i c0l = _mm_add_epi32(a0, b0l); // 1l/0.5t
      __m128i c0h = _mm_add_epi32(a0, b0h); // 1l/0.5t
      __m256 c0 = _mm256_set_m128(c0h, c0l); // 3l/1t
      r = _mm256_xor_ps(r, c0); // 1l/1t

      __m128i c00l = _mm_add_epi32(a0, b1l); // 1l/0.5t
      __m128i c00h = _mm_add_epi32(a0, b1h); // 1l/0.5t
      __m256 c00 = _mm256_set_m128(c00h, c00l); // 3l/1t
      r = _mm256_xor_ps(r, c00); // 1l/1t
      
      __m128i c1l = _mm_add_epi32(a1, b0l); // 1l/0.5t
      __m128i c1h = _mm_add_epi32(a1, b0h); // 1l/0.5t
      __m256 c1 = _mm256_set_m128(c1h, c1l); // 3l/1t
      r = _mm256_xor_ps(r, c1); // 1l/1t

      __m128i c11l = _mm_add_epi32(a1, b1l); // 1l/0.5t
      __m128i c11h = _mm_add_epi32(a1, b1h); // 1l/0.5t
      __m256 c11 = _mm256_set_m128(c11h, c11l); // 3l/1t
      r = _mm256_xor_ps(r, c11); // 1l/1t

      __m128i c2l = _mm_add_epi32(a2, b0l); // 1l/0.5t
      __m128i c2h = _mm_add_epi32(a2, b0h); // 1l/0.5t
      __m256 c2 = _mm256_set_m128(c2h, c2l); // 3l/1t
      r = _mm256_xor_ps(r, c2); // 1l/1t

      __m128i c22l = _mm_add_epi32(a2, b1l); // 1l/0.5t
      __m128i c22h = _mm_add_epi32(a2, b1h); // 1l/0.5t
      __m256 c22 = _mm256_set_m128(c22h, c22l); // 3l/1t
      r = _mm256_xor_ps(r, c22); // 1l/1t

      __m128i c3l = _mm_add_epi32(a3, b0l); // 1l/0.5t
      __m128i c3h = _mm_add_epi32(a3, b0h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c3l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c3h); // 1l/0.3t

      __m128i c33l = _mm_add_epi32(a3, b1l); // 1l/0.5t
      __m128i c33h = _mm_add_epi32(a3, b1h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c33l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c33h); // 1l/0.3t

      __m128i c4l = _mm_add_epi32(a4, b0l); // 1l/0.5t
      __m128i c4h = _mm_add_epi32(a4, b0h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c4l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c4h); // 1l/0.3t

      __m128i c44l = _mm_add_epi32(a4, b1l); // 1l/0.5t
      __m128i c44h = _mm_add_epi32(a4, b1h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c44l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c44h); // 1l/0.3t

      __m128i c5l = _mm_add_epi32(a5, b0l); // 1l/0.5t
      __m128i c5h = _mm_add_epi32(a5, b0h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c5l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c5h); // 1l/0.3t

      __m128i c55l = _mm_add_epi32(a5, b1l); // 1l/0.5t
      __m128i c55h = _mm_add_epi32(a5, b1h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c55l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c55h); // 1l/0.3t

      __m128i c6l = _mm_add_epi32(a6, b0l); // 1l/0.5t
      __m128i c6h = _mm_add_epi32(a6, b0h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c6l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c6h); // 1l/0.3t

      __m128i c66l = _mm_add_epi32(a6, b1l); // 1l/0.5t
      __m128i c66h = _mm_add_epi32(a6, b1h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c66l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c66h); // 1l/0.3t

      __m128i c77l = _mm_add_epi32(a7, b1l); // 1l/0.5t
      __m128i c77h = _mm_add_epi32(a7, b1h); // 1l/0.5t
      rh = _mm_xor_si128(rh, c77l); // 1l/0.3t
      rh = _mm_xor_si128(rh, c77h); // 1l/0.3t
    }
  }
  // return extract256(r);
  return extract256(r) ^ extract(rh);
}

int main() {
  scanf("%d", &N);
  for(int i=0;i<N;i++) {
    scanf("%d", a+i);
  }
  for(int i=0;i<N;i++) {
    scanf("%d", b+i);
  }
  int ans = solve();
  printf("%d\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int extract256(__m256)':
a.cc:21:18: error: cannot convert '__m128' to '__m128i'
   21 |   return extract(l) ^ extract(h);
      |                  ^
      |                  |
      |                  __m128
a.cc:8:21: note:   initializing argument 1 of 'int extract(__m128i)'
    8 | int extract(__m128i ret) {
      |             ~~~~~~~~^~~
a.cc:21:31: error: cannot convert '__m128' to '__m128i'
   21 |   return extract(l) ^ extract(h);
      |                               ^
      |                               |
      |                               __m128
a.cc:8:21: note:   initializing argument 1 of 'int extract(__m128i)'
    8 | int extract(__m128i ret) {
      |             ~~~~~~~~^~~
a.cc: In function 'int solve()':
a.cc:49:35: error: cannot convert '__m128i' to '__m128'
   49 |       __m256 c0 = _mm256_set_m128(c0h, c0l); // 3l/1t
      |                                   ^~~
      |                                   |
      |                                   __m128i
In file included from /usr/lib/gcc/x86_64-linux-gnu/14/include/immintrin.h:43,
                 from a.cc:1:
/usr/lib/gcc/x86_64-linux-gnu/14/include/avxintrin.h:1525:26: note:   initializing argument 1 of '__m256 _mm256_set_m128(__m128, __m128)'
 1525 | _mm256_set_m128 ( __m128 __H, __m128 __L)
      |                   ~~~~~~~^~~
a.cc:54:36: error: cannot convert '__m128i' to '__m128'
   54 |       __m256 c00 = _mm256_set_m128(c00h, c00l); // 3l/1t
      |                                    ^~~~
      |                                    |
      |                                    __m128i
/usr/lib/gcc/x86_64-linux-gnu/14/include/avxintrin.h:1525:26: note:   initializing argument 1 of '__m256 _mm256_set_m128(__m128, __m128)'
 1525 | _mm256_set_m128 ( __m128 __H, __m128 __L)
      |                   ~~~~~~~^~~
a.cc:59:35: error: cannot convert '__m128i' to '__m128'
   59 |       __m256 c1 = _mm256_set_m128(c1h, c1l); // 3l/1t
      |                                   ^~~
      |                                   |
      |                                   __m128i
/usr/lib/gcc/x86_64-linux-gnu/14/include/avxintrin.h:1525:26: note:   initializing argument 1 of '__m256 _mm256_set_m128(__m128, __m128)'
 1525 | _mm256_set_m128 ( __m128 __H, __m128 __L)
      |                   ~~~~~~~^~~
a.cc:64:36: error: cannot convert '__m128i' to '__m128'
   64 |       __m256 c11 = _mm256_set_m128(c11h, c11l); // 3l/1t
      |                                    ^~~~
      |                                    |
      |                                    __m128i
/usr/lib/gcc/x86_64-linux-gnu/14/include/avxintrin.h:1525:26: note:   initializing argument 1 of '__m256 _mm256_set_m128(__m128, __m128)'
 1525 | _mm256_set_m128 ( __m128 __H, __m128 __L)
      |                   ~~~~~~~^~~
a.cc:69:35: error: cannot convert '__m128i' to '__m128'
   69 |       __m256 c2 = _mm256_set_m128(c2h, c2l); // 3l/1t
      |                                   ^~~
      |                                   |
      |                                   __m128i
/usr/lib/gcc/x86_64-linux-gnu/14/include/avxintrin.h:1525:26: note:   initializing argument 1 of '__m256 _mm256_set_m128(__m128, __m128)'
 1525 | _mm256_set_m128 ( __m128 __H, __m128 __L)
      |                   ~~~~~~~^~~
a.cc:74:36: error: cannot convert '__m128i' to '__m128'
   74 |       __m256 c22 = _mm256_set_m128(c22h, c22l); // 3l/1t
      |                                    ^~~~
      |                                    |
      |                                    __m128i
/usr/lib/gcc/x86_64-linux-gnu/14/include/avxintrin.h:1525:26: note:   initializing argument 1 of '__m256 _mm256_set_m128(__m128, __m128)'
 1525 | _mm256_set_m128 ( __m128 __H, __m128 __L)
      |                   ~~~~~~~^~~
a.cc: In function 'int extract256(__m256)':
a.cc:18:5: note: the ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
   18 | int extract256(__m256 r) {
      |     ^~~~~~~~~~
a.cc: In function 'int solve()':
a.cc:25:32: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
   25 |   __m256 r = _mm256_setzero_ps();
      |                                ^