avx2: refactor mm256_hadd_epi16 to use simde_x_mm_deinterleave*_epi16
@@ -1568,26 +1568,17 @@ simde_mm256_hadd_epi16 (simde__m256i a, simde__m256i b) {
#if defined(SIMDE_X86_AVX2_NATIVE)
return _mm256_hadd_epi16(a, b);
#else
- simde__m256i_private r_;
- simde__m256i_private a_ = simde__m256i_to_private(a);
- simde__m256i_private b_ = simde__m256i_to_private(b);
+ simde__m256i_private
+ r_,
+ a_ = simde__m256i_to_private(a),
+ b_ = simde__m256i_to_private(b);
- r_.i16[0] = a_.i16[1] + a_.i16[0];
- r_.i16[1] = a_.i16[3] + a_.i16[2];
- r_.i16[2] = a_.i16[5] + a_.i16[4];
- r_.i16[3] = a_.i16[7] + a_.i16[6];
- r_.i16[4] = b_.i16[1] + b_.i16[0];
- r_.i16[5] = b_.i16[3] + b_.i16[2];
- r_.i16[6] = b_.i16[5] + b_.i16[4];
- r_.i16[7] = b_.i16[7] + b_.i16[6];
- r_.i16[8] = a_.i16[9] + a_.i16[8];
- r_.i16[9] = a_.i16[11] + a_.i16[10];
- r_.i16[10] = a_.i16[13] + a_.i16[12];
- r_.i16[11] = a_.i16[15] + a_.i16[14];
- r_.i16[12] = b_.i16[9] + b_.i16[8];
- r_.i16[13] = b_.i16[11] + b_.i16[10];
- r_.i16[14] = b_.i16[13] + b_.i16[12];
- r_.i16[15] = b_.i16[15] + b_.i16[14];
+ SIMDE_VECTORIZE
+ for (size_t i = 0 ; i < (sizeof(r_.m128i) / sizeof(r_.m128i[0])) ; i++ ) {
+ const simde__m128i even = simde_x_mm_deinterleaveeven_epi16(a_.m128i[i], b_.m128i[i]);
+ const simde__m128i odd = simde_x_mm_deinterleaveodd_epi16(a_.m128i[i], b_.m128i[i]);
+ r_.m128i[i] = simde_mm_add_epi16(even, odd);
+ }
return simde__m256i_from_private(r_);
#endif
