diff --git a/include/ircd/simd/all.h b/include/ircd/simd/all.h new file mode 100644 index 000000000..e26018aa7 --- /dev/null +++ b/include/ircd/simd/all.h @@ -0,0 +1,116 @@ +// The Construct +// +// Copyright (C) The Construct Developers, Authors & Contributors +// Copyright (C) 2016-2020 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for all +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_SIMD_ALL_H + +namespace ircd::simd +{ + /// Convenience wrapper around lateral()[0] with the most + /// efficient lane type conversions made. + template + bool all(const T) noexcept = delete; +} + +template<> +inline bool +ircd::simd::all(const u64x8 a) +noexcept +{ + return lateral(a)[0] == -1UL; +} + +template<> +inline bool +ircd::simd::all(const u64x4 a) +noexcept +{ + return lateral(a)[0] == -1UL; +} + +template<> +inline bool +ircd::simd::all(const u64x2 a) +noexcept +{ + return lateral(a)[0] == -1UL; +} + +template<> +inline bool +ircd::simd::all(const u32x16 a) +noexcept +{ + return all(u64x8(a)); +} + +template<> +inline bool +ircd::simd::all(const u32x8 a) +noexcept +{ + return all(u64x4(a)); +} + +template<> +inline bool +ircd::simd::all(const u32x4 a) +noexcept +{ + return all(u64x2(a)); +} + +template<> +inline bool +ircd::simd::all(const u16x32 a) +noexcept +{ + return all(u64x8(a)); +} + +template<> +inline bool +ircd::simd::all(const u16x16 a) +noexcept +{ + return all(u64x4(a)); +} + +template<> +inline bool +ircd::simd::all(const u16x8 a) +noexcept +{ + return all(u64x2(a)); +} + +template<> +inline bool +ircd::simd::all(const u8x64 a) +noexcept +{ + return all(u64x8(a)); +} + +template<> +inline bool +ircd::simd::all(const u8x32 a) +noexcept +{ + return all(u64x4(a)); +} + +template<> +inline bool +ircd::simd::all(const u8x16 a) +noexcept +{ + return all(u64x2(a)); +} diff --git a/include/ircd/simd/simd.h b/include/ircd/simd/simd.h index 07bd39c01..084c1359e 100644 --- a/include/ircd/simd/simd.h +++ b/include/ircd/simd/simd.h @@ -31,6 +31,7 @@ #include "tzcnt.h" #include "lateral.h" #include "any.h" +#include "all.h" #include "stream.h" #include "print.h"