@@ -7286,6 +7286,52 @@ HWY_INLINE Vec<D> Lookup32(D d, const T* HWY_RESTRICT table, VI indices) {
72867286 }
72877287}
72887288
7289+ // ------------------------------ Lookup64
7290+
7291+ #if (defined(HWY_NATIVE_LOOKUP64) == defined(HWY_TARGET_TOGGLE)) || HWY_IDE
7292+ #ifdef HWY_NATIVE_LOOKUP64
7293+ #undef HWY_NATIVE_LOOKUP64
7294+ #else
7295+ #define HWY_NATIVE_LOOKUP64
7296+ #endif
7297+
7298+ template <class D , typename T = TFromD<D>, class VI >
7299+ HWY_INLINE Vec<D> Lookup64 (D d, const T* HWY_RESTRICT table, VI indices) {
7300+ const DFromV<VI > di;
7301+ static_assert (sizeof (T) == 1 , " Lookup64 requires 8-bit table lanes" );
7302+ static_assert (sizeof (T) == sizeof (TFromD<decltype (di)>),
7303+ " Index/vector must have same lane size" );
7304+ HWY_IF_CONSTEXPR (HWY_IS_DEBUG_BUILD ) {
7305+ HWY_DASSERT (Lanes (d) >= 32 );
7306+ HWY_DASSERT (AllTrue (di, Lt (indices, Set (di, 64 ))));
7307+ }
7308+
7309+ HWY_IF_CONSTEXPR (!HWY_HAVE_SCALABLE ) {
7310+ HWY_IF_CONSTEXPR (MaxLanes (d) >= 64 ) {
7311+ const CappedTag<T, 64 > d64;
7312+ const Vec<D> t0 = ZeroExtendResizeBitCast (d, d64, Load (d64, table));
7313+ return TableLookupLanes (t0, IndicesFromVec (d, indices));
7314+ }
7315+ HWY_IF_CONSTEXPR (MaxLanes (d) < 64 ) {
7316+ const Vec<D> t0 = Load (d, table);
7317+ const Vec<D> t1 = Load (d, table + 32 );
7318+ return TwoTablesLookupLanes (d, t0, t1, IndicesFromVec (d, indices));
7319+ }
7320+ }
7321+
7322+ HWY_IF_CONSTEXPR (HWY_HAVE_SCALABLE ) {
7323+ const Vec<D> t0 = LoadN (d, table, 32 );
7324+ const Vec<D> t1 = LoadN (d, table + 32 , 32 );
7325+ const Mask<decltype (di)> ge_32 = Ge (indices, Set (di, 32 ));
7326+ const VI idx_for_t1 = Sub (indices, Set (di, 32 ));
7327+ const Vec<D> r0 = TableLookupLanes (t0, IndicesFromVec (d, indices));
7328+ const Vec<D> r1 = TableLookupLanes (t1, IndicesFromVec (d, idx_for_t1));
7329+ return IfThenElse (RebindMask (d, ge_32), r1, r0);
7330+ }
7331+ }
7332+
7333+ #endif // HWY_NATIVE_LOOKUP64
7334+
72897335// ------------------------------ Reverse2, Reverse4, Reverse8 (8-bit)
72907336
72917337#if (defined(HWY_NATIVE_REVERSE2_8) == defined(HWY_TARGET_TOGGLE)) || HWY_IDE
0 commit comments