mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-10-11 22:49:55 +00:00
BufferUtils: Address reviews
-drop iota16, remove avx2 check, better reduction
This commit is contained in:
@@ -470,7 +470,7 @@ namespace
|
||||
#if defined(ARCH_X64)
|
||||
const upload_untouched_skip_restart_dispatch s_avx512_upload_untouched_skip_restart_dispatch =
|
||||
{
|
||||
s_use_avx2 ? upload_swapped_avx2_skip_restart<u16> : upload_untouched_skip_restart<u16>,
|
||||
upload_swapped_avx2_skip_restart<u16>,
|
||||
upload_u32_swapped_avx3_skip_restart,
|
||||
};
|
||||
|
||||
@@ -748,13 +748,10 @@ void iota16(u16* dst, u32 count)
|
||||
iota16_avx2(dst, count);
|
||||
return;
|
||||
}
|
||||
#elif defined(ARCH_ARM64)
|
||||
iota16_neon(dst, count);
|
||||
return;
|
||||
#endif
|
||||
|
||||
u32 i = 0;
|
||||
#if defined(ARCH_X64)
|
||||
#if defined(ARCH_X64) || defined(ARCH_ARM64)
|
||||
// Force 16-byte alignment
|
||||
const uptr mem_addr = reinterpret_cast<uptr>(dst);
|
||||
const u32 head = std::min<u32>(count, ((0 - mem_addr) & 15) / sizeof(u16));
|
||||
|
||||
@@ -165,12 +165,25 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
alignas(32) T min_lanes[lanes];
|
||||
alignas(32) T max_lanes[lanes];
|
||||
_mm256_store_si256(reinterpret_cast<__m256i*>(min_lanes), min);
|
||||
_mm256_store_si256(reinterpret_cast<__m256i*>(max_lanes), max);
|
||||
T min_index = *std::min_element(std::begin(min_lanes), std::end(min_lanes));
|
||||
T max_index = *std::max_element(std::begin(max_lanes), std::end(max_lanes));
|
||||
T min_index, max_index;
|
||||
if constexpr (sizeof(T) == 2)
|
||||
{
|
||||
const auto min128 = _mm_min_epu16(_mm256_castsi256_si128(min), _mm256_extracti128_si256(min, 1));
|
||||
const auto max128 = _mm_max_epu16(_mm256_castsi256_si128(max), _mm256_extracti128_si256(max, 1));
|
||||
min_index = static_cast<T>(_mm_cvtsi128_si32(_mm_minpos_epu16(min128)));
|
||||
max_index = static_cast<T>(~_mm_cvtsi128_si32(_mm_minpos_epu16(_mm_xor_si128(max128, _mm_set1_epi32(-1)))));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto min128 = _mm_min_epu32(_mm256_castsi256_si128(min), _mm256_extracti128_si256(min, 1));
|
||||
auto max128 = _mm_max_epu32(_mm256_castsi256_si128(max), _mm256_extracti128_si256(max, 1));
|
||||
min128 = _mm_min_epu32(min128, _mm_shuffle_epi32(min128, _MM_SHUFFLE(1, 0, 3, 2)));
|
||||
max128 = _mm_max_epu32(max128, _mm_shuffle_epi32(max128, _MM_SHUFFLE(1, 0, 3, 2)));
|
||||
min128 = _mm_min_epu32(min128, _mm_shuffle_epi32(min128, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
max128 = _mm_max_epu32(max128, _mm_shuffle_epi32(max128, _MM_SHUFFLE(2, 3, 0, 1)));
|
||||
min_index = static_cast<T>(_mm_cvtsi128_si32(min128));
|
||||
max_index = static_cast<T>(_mm_cvtsi128_si32(max128));
|
||||
}
|
||||
|
||||
for (; i < count; ++i)
|
||||
{
|
||||
|
||||
@@ -122,22 +122,4 @@ namespace
|
||||
|
||||
return (u64{max_index} << 32) | min_index;
|
||||
}
|
||||
|
||||
void iota16_neon(u16* dst, u32 count)
|
||||
{
|
||||
const u16 initial[] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
auto value = vld1q_u16(initial);
|
||||
u32 i = 0;
|
||||
|
||||
for (; count - i >= 8; i += 8)
|
||||
{
|
||||
vst1q_u16(dst + i, value);
|
||||
value = vaddq_u16(value, vdupq_n_u16(8));
|
||||
}
|
||||
|
||||
for (; i < count; ++i)
|
||||
{
|
||||
dst[i] = static_cast<u16>(i);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user