Skip to content

Commit 9741c03

Browse files
author
Yuqi Gu
committed
Add fallback methods for zip_hi and zip_lo
Change-Id: If2aca405292017839dffa2800f900038247d1ad5 Signed-off-by: Yuqi Gu <guyuqi@apache.com>
1 parent ae4c540 commit 9741c03

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

include/xsimd/types/xsimd_fallback.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,28 @@ namespace xsimd
928928
{
929929
XSIMD_FALLBACK_MAPPING_LOOP(batch_bool, std::isnan(x[i]))
930930
}
931+
932+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
933+
{
934+
batch_type b_lo;
935+
for (std::size_t i = 0, j = 0; i < N/2; ++i, j = j + 2)
936+
{
937+
b_lo[j] = lhs[i];
938+
b_lo[j + 1] = rhs[i];
939+
}
940+
return b_lo;
941+
}
942+
943+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
944+
{
945+
batch_type b_hi;
946+
for (std::size_t i = 0, j = 0; i < N/2; ++i, j = j + 2)
947+
{
948+
b_hi[j] = lhs[i + N/2];
949+
b_hi[j + 1] = rhs[i+ N/2];
950+
}
951+
return b_hi;
952+
}
931953
};
932954
}
933955

test/test_shuffle_128.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ class shuffle_128_test : public testing::Test
6262

6363
void shuffle_128_low_high()
6464
{
65-
auto shuffle_base = xsimd::init_shuffle_128_base<value_type, size>{};
65+
xsimd::init_shuffle_128_base<value_type, size> shuffle_base;
6666
auto shuffle_base_vecs = shuffle_base.create_vectors();
67-
auto v_lhs = shuffle_base_vecs[0];
68-
auto v_rhs = shuffle_base_vecs[1];
69-
auto v_exp_lo = shuffle_base_vecs[2];
70-
auto v_exp_hi = shuffle_base_vecs[3];
67+
auto v_lhs = shuffle_base_vecs[0];
68+
auto v_rhs = shuffle_base_vecs[1];
69+
auto v_exp_lo = shuffle_base_vecs[2];
70+
auto v_exp_hi = shuffle_base_vecs[3];
7171

7272
B b_lhs, b_rhs, b_exp_lo, b_exp_hi, b_res_lo, b_res_hi;
7373
b_lhs.load_unaligned(v_lhs.data());

0 commit comments

Comments
 (0)