Skip to content

Commit f525867

Browse files
committed
Split by HWY_NATIVE_SCATTER/HWY_NATIVE_GATHER
1 parent 92c0c2e commit f525867

1 file changed

Lines changed: 27 additions & 17 deletions

File tree

hwy/ops/generic_ops-inl.h

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,25 @@ HWY_API void MaskedScatterIndex(VFromD<D> v, MFromD<D> m, D d,
26792679
}
26802680
}
26812681

2682+
template <class D, typename T = TFromD<D>>
2683+
HWY_API void ScatterIndexN(VFromD<D> v, D d, T* HWY_RESTRICT base,
2684+
VFromD<RebindToSigned<D>> index,
2685+
const size_t max_lanes_to_store) {
2686+
const RebindToSigned<decltype(d)> di;
2687+
using TI = TFromD<decltype(di)>;
2688+
static_assert(sizeof(T) == sizeof(TI), "Index/lane size must match");
2689+
2690+
for (size_t i = 0; i < MaxLanes(d); ++i) {
2691+
if (i < max_lanes_to_store) base[ExtractLane(index, i)] = ExtractLane(v, i);
2692+
}
2693+
}
2694+
#else
2695+
template <class D, typename T = TFromD<D>>
2696+
HWY_API void ScatterIndexN(VFromD<D> v, D d, T* HWY_RESTRICT base,
2697+
VFromD<RebindToSigned<D>> index,
2698+
const size_t max_lanes_to_store) {
2699+
MaskedScatterIndex(v, FirstN(d, max_lanes_to_store), d, base, index);
2700+
}
26822701
#endif // (defined(HWY_NATIVE_SCATTER) == defined(HWY_TARGET_TOGGLE))
26832702

26842703
// ------------------------------ Gather
@@ -2774,23 +2793,6 @@ HWY_API VFromD<D> MaskedGatherIndexOr(VFromD<D> no, MFromD<D> m, D d,
27742793
return Load(d, lanes);
27752794
}
27762795

2777-
#endif // (defined(HWY_NATIVE_GATHER) == defined(HWY_TARGET_TOGGLE))
2778-
2779-
// ------------------------------ ScatterN/GatherN
2780-
2781-
template <class D, typename T = TFromD<D>>
2782-
HWY_API void ScatterIndexN(VFromD<D> v, D d, T* HWY_RESTRICT base,
2783-
VFromD<RebindToSigned<D>> index,
2784-
const size_t max_lanes_to_store) {
2785-
const RebindToSigned<decltype(d)> di;
2786-
using TI = TFromD<decltype(di)>;
2787-
static_assert(sizeof(T) == sizeof(TI), "Index/lane size must match");
2788-
2789-
for (size_t i = 0; i < MaxLanes(d); ++i) {
2790-
if (i < max_lanes_to_store) base[ExtractLane(index, i)] = ExtractLane(v, i);
2791-
}
2792-
}
2793-
27942796
template <class D, typename T = TFromD<D>>
27952797
HWY_API VFromD<D> GatherIndexN(D d, const T* HWY_RESTRICT base,
27962798
VFromD<RebindToSigned<D>> index,
@@ -2806,6 +2808,14 @@ HWY_API VFromD<D> GatherIndexN(D d, const T* HWY_RESTRICT base,
28062808
}
28072809
return v;
28082810
}
2811+
#else
2812+
template <class D, typename T = TFromD<D>>
2813+
HWY_API VFromD<D> GatherIndexN(D d, const T* HWY_RESTRICT base,
2814+
VFromD<RebindToSigned<D>> index,
2815+
const size_t max_lanes_to_load) {
2816+
return MaskedGatherIndex(FirstN(d, max_lanes_to_load), d, base, index);
2817+
}
2818+
#endif // (defined(HWY_NATIVE_GATHER) == defined(HWY_TARGET_TOGGLE))
28092819

28102820
// ------------------------------ Integer AbsDiff and SumsOf8AbsDiff
28112821

0 commit comments

Comments
 (0)