Skip to content

Commit 9c0bd33

Browse files
WIP
1 parent c586776 commit 9c0bd33

File tree

3 files changed

+27
-61
lines changed

3 files changed

+27
-61
lines changed

include/xsimd/arch/xsimd_altivec.hpp

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ namespace xsimd
889889

890890
#endif
891891
// load_aligned
892-
template <class A, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
892+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
893893
XSIMD_INLINE batch<T, A> load_aligned(T const* mem, convert<T>, requires_arch<altivec>) noexcept
894894
{
895895
return vec_ld(0, mem);
@@ -1115,25 +1115,15 @@ namespace xsimd
11151115
{
11161116
return _mm_min_pd(self, other);
11171117
}
1118+
#endif
11181119

11191120
// mul
1120-
template <class A>
1121-
XSIMD_INLINE batch<float, A> mul(batch<float, A> const& self, batch<float, A> const& other, requires_arch<sse2>) noexcept
1122-
{
1123-
return _mm_mul_ps(self, other);
1124-
}
1125-
template <class A>
1126-
XSIMD_INLINE batch<double, A> mul(batch<double, A> const& self, batch<double, A> const& other, requires_arch<sse2>) noexcept
1127-
{
1128-
return _mm_mul_pd(self, other);
1129-
}
1130-
1131-
// mul
1132-
template <class A>
1133-
XSIMD_INLINE batch<int16_t, A> mul(batch<int16_t, A> const& self, batch<int16_t, A> const& other, requires_arch<sse2>) noexcept
1121+
template <class A, class T, typename std::enable_if<std::is_scalar<T>::value, void>::type>
1122+
XSIMD_INLINE batch<T, A> mul(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
11341123
{
1135-
return _mm_mullo_epi16(self, other);
1124+
return vec_mul(self, other);
11361125
}
1126+
#if 0
11371127

11381128
// nearbyint_as_int
11391129
template <class A>
@@ -1388,7 +1378,7 @@ namespace xsimd
13881378
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
13891379
XSIMD_INLINE batch<T, A> sadd(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
13901380
{
1391-
return vec_adds(self, other);
1381+
return vec_adds(self, other);
13921382
}
13931383
#if 0
13941384

@@ -1454,17 +1444,16 @@ namespace xsimd
14541444
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
14551445
XSIMD_INLINE batch<T, A> ssub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
14561446
{
1457-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
1458-
{
1459-
return vec_subs(self, other);
1460-
}
1461-
else
1462-
{
1463-
return ssub(self, other, common {});
1464-
}
1447+
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
1448+
{
1449+
return vec_subs(self, other);
1450+
}
1451+
else
1452+
{
1453+
return ssub(self, other, common {});
1454+
}
14651455
}
14661456

1467-
14681457
// store_aligned
14691458
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
14701459
XSIMD_INLINE void store_aligned(T* mem, batch<T, A> const& self, requires_arch<altivec>) noexcept
@@ -1479,44 +1468,14 @@ namespace xsimd
14791468
*(typename batch<T, A>::register_type)mem = self;
14801469
}
14811470

1482-
#if 0
14831471
// sub
1484-
template <class A>
1485-
XSIMD_INLINE batch<float, A> sub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<sse2>) noexcept
1486-
{
1487-
return _mm_sub_ps(self, other);
1488-
}
1489-
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
1490-
XSIMD_INLINE batch<T, A> sub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<sse2>) noexcept
1491-
{
1492-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
1493-
{
1494-
return _mm_sub_epi8(self, other);
1495-
}
1496-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
1497-
{
1498-
return _mm_sub_epi16(self, other);
1499-
}
1500-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
1501-
{
1502-
return _mm_sub_epi32(self, other);
1503-
}
1504-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
1505-
{
1506-
return _mm_sub_epi64(self, other);
1507-
}
1508-
else
1509-
{
1510-
assert(false && "unsupported arch/op combination");
1511-
return {};
1512-
}
1513-
}
1514-
template <class A>
1515-
XSIMD_INLINE batch<double, A> sub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<sse2>) noexcept
1472+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
1473+
XSIMD_INLINE batch<T, A> sub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
15161474
{
1517-
return _mm_sub_pd(self, other);
1475+
return vec_sub(self, other);
15181476
}
15191477

1478+
#if 0
15201479
// swizzle
15211480

15221481
template <class A, uint32_t V0, uint32_t V1, uint32_t V2, uint32_t V3>

include/xsimd/config/xsimd_arch.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,16 @@ namespace xsimd
169169
using all_sve_architectures = arch_list<detail::sve<512>, detail::sve<256>, detail::sve<128>>;
170170
using all_rvv_architectures = arch_list<detail::rvv<512>, detail::rvv<256>, detail::rvv<128>>;
171171
using all_arm_architectures = typename detail::join<all_sve_architectures, arch_list<i8mm<neon64>, neon64, neon>>::type;
172+
using all_power_architectures = arch_list<altivec>;
172173
using all_riscv_architectures = all_rvv_architectures;
173174
using all_wasm_architectures = arch_list<wasm>;
174-
using all_architectures = typename detail::join<all_riscv_architectures, all_wasm_architectures, all_arm_architectures, all_x86_architectures>::type;
175+
using all_architectures = typename detail::join<all_power_architectures, all_riscv_architectures, all_wasm_architectures, all_arm_architectures, all_x86_architectures>::type;
175176

176177
using supported_architectures = typename detail::supported<all_architectures>::type;
177178

178179
using x86_arch = typename detail::supported<all_x86_architectures>::type::best;
179180
using arm_arch = typename detail::supported<all_arm_architectures>::type::best;
181+
using power_arch = typename detail::supported<all_power_architectures>::type::best;
180182
using riscv_arch = typename detail::supported<all_riscv_architectures>::type::best;
181183
using best_arch = typename supported_architectures::best;
182184

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace xsimd
8484
ARCH_FIELD_EX_REUSE(detail::rvv<256>, rvv)
8585
ARCH_FIELD_EX_REUSE(detail::rvv<128>, rvv)
8686
ARCH_FIELD(wasm)
87+
ARCH_FIELD(altivec)
8788

8889
#undef ARCH_FIELD
8990

@@ -95,6 +96,10 @@ namespace xsimd
9596
wasm = 1;
9697
#endif
9798

99+
#if XSIMD_WITH_ALTIVEC
100+
altivec = 1;
101+
#endif
102+
98103
#if defined(__aarch64__) || defined(_M_ARM64)
99104
neon = 1;
100105
neon64 = 1;

0 commit comments

Comments
 (0)