Skip to content

Commit 8e0c6ff

Browse files
authored
Vector algorithms cleanups (#6089)
1 parent cb3428a commit 8e0c6ff

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

stl/src/vector_algorithms.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,28 +2061,28 @@ namespace {
20612061
}
20622062

20632063
static _Vec_t _H_min(const _Vec_t _Cur) noexcept {
2064-
int64x2_t _Swapped = vextq_s64(_Cur, _Cur, 1);
2065-
uint64x2_t _Mask_lt = vcltq_s64(_Swapped, _Cur);
2064+
const int64x2_t _Swapped = vextq_s64(_Cur, _Cur, 1);
2065+
const uint64x2_t _Mask_lt = vcltq_s64(_Swapped, _Cur);
20662066
return vbslq_s64(_Mask_lt, _Swapped, _Cur);
20672067
}
20682068

20692069
static _Vec_t _H_max(const _Vec_t _Cur) noexcept {
2070-
int64x2_t _Swapped = vextq_s64(_Cur, _Cur, 1);
2071-
uint64x2_t _Mask_gt = vcgtq_s64(_Swapped, _Cur);
2070+
const int64x2_t _Swapped = vextq_s64(_Cur, _Cur, 1);
2071+
const uint64x2_t _Mask_gt = vcgtq_s64(_Swapped, _Cur);
20722072
return vbslq_s64(_Mask_gt, _Swapped, _Cur);
20732073
}
20742074

20752075
static _Vec_t _H_min_u(const _Vec_t _Cur) noexcept {
2076-
const uint64x2_t _Cur_u = vreinterpretq_u64_s64(_Cur);
2077-
uint64x2_t _Swapped = vextq_u64(_Cur_u, _Cur_u, 1);
2078-
uint64x2_t _Mask_lt = vcltq_u64(_Swapped, _Cur_u);
2076+
const uint64x2_t _Cur_u = vreinterpretq_u64_s64(_Cur);
2077+
const uint64x2_t _Swapped = vextq_u64(_Cur_u, _Cur_u, 1);
2078+
const uint64x2_t _Mask_lt = vcltq_u64(_Swapped, _Cur_u);
20792079
return vreinterpretq_s64_u64(vbslq_u64(_Mask_lt, _Swapped, _Cur_u));
20802080
}
20812081

20822082
static _Vec_t _H_max_u(const _Vec_t _Cur) noexcept {
2083-
const uint64x2_t _Cur_u = vreinterpretq_u64_s64(_Cur);
2084-
uint64x2_t _Swapped = vextq_u64(_Cur_u, _Cur_u, 1);
2085-
uint64x2_t _Mask_gt = vcgtq_u64(_Swapped, _Cur_u);
2083+
const uint64x2_t _Cur_u = vreinterpretq_u64_s64(_Cur);
2084+
const uint64x2_t _Swapped = vextq_u64(_Cur_u, _Cur_u, 1);
2085+
const uint64x2_t _Mask_gt = vcgtq_u64(_Swapped, _Cur_u);
20862086
return vreinterpretq_s64_u64(vbslq_u64(_Mask_gt, _Swapped, _Cur_u));
20872087
}
20882088

@@ -4056,13 +4056,13 @@ namespace {
40564056
}
40574057

40584058
static uint64_t _Match_mask_eq(const uint8x16_t _Cmp_lo, const uint8x16_t _Cmp_hi) noexcept {
4059-
auto _Cmp = vreinterpretq_u64_u8(vorrq_u8(_Cmp_lo, _Cmp_hi));
4059+
const auto _Cmp = vreinterpretq_u64_u8(vorrq_u8(_Cmp_lo, _Cmp_hi));
40604060
return vgetq_lane_u64(vpaddq_u64(_Cmp, _Cmp), 0);
40614061
}
40624062

40634063
static uint64_t _Match_mask_ne(const uint8x16_t _Cmp_lo, const uint8x16_t _Cmp_hi) noexcept {
4064-
auto _Cmp = vminq_u8(_Cmp_lo, _Cmp_hi);
4065-
auto _Comb = vreinterpretq_u64_u8(vpminq_u8(_Cmp, _Cmp));
4064+
const auto _Cmp = vminq_u8(_Cmp_lo, _Cmp_hi);
4065+
const auto _Comb = vreinterpretq_u64_u8(vpminq_u8(_Cmp, _Cmp));
40664066
return vgetq_lane_u64(_Comb, 0) ^ 0xFFFF'FFFF'FFFF'FFFF;
40674067
}
40684068
};
@@ -4103,13 +4103,13 @@ namespace {
41034103
}
41044104

41054105
static uint64_t _Match_mask_eq(const uint16x8_t _Cmp_lo, const uint16x8_t _Cmp_hi) noexcept {
4106-
uint8x8_t _Cmp = vaddhn_u16(_Cmp_lo, _Cmp_hi);
4106+
const uint8x8_t _Cmp = vaddhn_u16(_Cmp_lo, _Cmp_hi);
41074107
return vget_lane_u64(vreinterpret_u64_u8(_Cmp), 0);
41084108
}
41094109

41104110
static uint64_t _Match_mask_ne(const uint16x8_t _Cmp_lo, const uint16x8_t _Cmp_hi) noexcept {
4111-
auto _Cmp = vminq_u16(_Cmp_lo, _Cmp_hi);
4112-
auto _Comb = vreinterpretq_u64_u16(vpminq_u16(_Cmp, _Cmp));
4111+
const auto _Cmp = vminq_u16(_Cmp_lo, _Cmp_hi);
4112+
const auto _Comb = vreinterpretq_u64_u16(vpminq_u16(_Cmp, _Cmp));
41134113
return vgetq_lane_u64(_Comb, 0) ^ 0xFFFF'FFFF'FFFF'FFFF;
41144114
}
41154115
};
@@ -4150,13 +4150,13 @@ namespace {
41504150
}
41514151

41524152
static uint64_t _Match_mask_eq(const uint32x4_t _Cmp_lo, const uint32x4_t _Cmp_hi) noexcept {
4153-
uint8x8_t _Cmp = vaddhn_u16(vreinterpretq_u16_u32(_Cmp_lo), vreinterpretq_u16_u32(_Cmp_hi));
4153+
const uint8x8_t _Cmp = vaddhn_u16(vreinterpretq_u16_u32(_Cmp_lo), vreinterpretq_u16_u32(_Cmp_hi));
41544154
return vget_lane_u64(vreinterpret_u64_u8(_Cmp), 0);
41554155
}
41564156

41574157
static uint64_t _Match_mask_ne(const uint32x4_t _Cmp_lo, const uint32x4_t _Cmp_hi) noexcept {
4158-
auto _Cmp = vminq_u32(_Cmp_lo, _Cmp_hi);
4159-
auto _Comb = vreinterpretq_u64_u32(vpminq_u32(_Cmp, _Cmp));
4158+
const auto _Cmp = vminq_u32(_Cmp_lo, _Cmp_hi);
4159+
const auto _Comb = vreinterpretq_u64_u32(vpminq_u32(_Cmp, _Cmp));
41604160
return vgetq_lane_u64(_Comb, 0) ^ 0xFFFF'FFFF'FFFF'FFFF;
41614161
}
41624162
};
@@ -4181,7 +4181,7 @@ namespace {
41814181
}
41824182

41834183
static uint64_t _Match_mask_eq(const uint64x2_t _Cmp_lo, const uint64x2_t _Cmp_hi) noexcept {
4184-
uint8x8_t _Cmp = vaddhn_u16(vreinterpretq_u16_u64(_Cmp_lo), vreinterpretq_u16_u64(_Cmp_hi));
4184+
const uint8x8_t _Cmp = vaddhn_u16(vreinterpretq_u16_u64(_Cmp_lo), vreinterpretq_u16_u64(_Cmp_hi));
41854185
return vget_lane_u64(vreinterpret_u64_u8(_Cmp), 0);
41864186
}
41874187

@@ -4347,8 +4347,8 @@ namespace {
43474347
const auto _Data_lo = _Traits::_Load_q(static_cast<const uint8_t*>(_First) + 0);
43484348
const auto _Data_hi = _Traits::_Load_q(static_cast<const uint8_t*>(_First) + 16);
43494349

4350-
auto _Comparison_lo = _Traits::_Cmp_neon_q(_Data_lo, _Comparand);
4351-
auto _Comparison_hi = _Traits::_Cmp_neon_q(_Data_hi, _Comparand);
4350+
const auto _Comparison_lo = _Traits::_Cmp_neon_q(_Data_lo, _Comparand);
4351+
const auto _Comparison_hi = _Traits::_Cmp_neon_q(_Data_hi, _Comparand);
43524352

43534353
// Use a fast check for the termination condition.
43544354
uint64_t _Any_match = 0;
@@ -4388,7 +4388,7 @@ namespace {
43884388
const auto _Comparand = _Traits::_Set_neon_q(_Val);
43894389
const auto _Data = _Traits::_Load_q(_First);
43904390

4391-
auto _Comparison = _Traits::_Cmp_neon_q(_Data, _Comparand);
4391+
const auto _Comparison = _Traits::_Cmp_neon_q(_Data, _Comparand);
43924392

43934393
auto _Match = _Traits::_Mask_q(_Comparison);
43944394
if constexpr (_Pred == _Predicate::_Not_equal) {
@@ -4409,7 +4409,7 @@ namespace {
44094409
const auto _Comparand = _Traits::_Set_neon(_Val);
44104410
const auto _Data = _Traits::_Load(_First);
44114411

4412-
auto _Comparison = _Traits::_Cmp_neon(_Data, _Comparand);
4412+
const auto _Comparison = _Traits::_Cmp_neon(_Data, _Comparand);
44134413

44144414
auto _Match = _Traits::_Mask(_Comparison);
44154415
if constexpr (_Pred == _Predicate::_Not_equal) {
@@ -5335,12 +5335,12 @@ namespace {
53355335
}
53365336

53375337
static size_t _Reduce_sse(const __m128i _Val) noexcept {
5338-
#ifdef _M_IX86
5338+
#ifdef _WIN64
5339+
return _mm_cvtsi128_si64(_Val) + _mm_extract_epi64(_Val, 1);
5340+
#else // ^^^ 64-bit / 32-bit vvv
53395341
return static_cast<uint32_t>(_mm_cvtsi128_si32(_Val))
53405342
+ static_cast<uint32_t>(_mm_extract_epi32(_Val, 2));
5341-
#else // ^^^ defined(_M_IX86) / defined(_M_X64) vvv
5342-
return _mm_cvtsi128_si64(_Val) + _mm_extract_epi64(_Val, 1);
5343-
#endif // ^^^ defined(_M_X64) ^^^
5343+
#endif // ^^^ 32-bit ^^^
53445344
}
53455345
};
53465346

@@ -9193,8 +9193,8 @@ namespace {
91939193
struct _Traits_8_avx : _Traits_avx {
91949194
static __m256i _Broadcast(const uint64_t _Data) noexcept {
91959195
#ifdef _WIN64
9196-
return _mm256_broadcastq_epi64(_mm_cvtsi64x_si128(_Data));
9197-
#else // ^^^ defined(_WIN64) / !defined(_WIN64), workaround, _mm_cvtsi64x_si128 does not compile vvv
9196+
return _mm256_broadcastq_epi64(_mm_cvtsi64_si128(_Data));
9197+
#else // ^^^ defined(_WIN64) / !defined(_WIN64), workaround, _mm_cvtsi64_si128 does not compile vvv
91989198
return _mm256_set1_epi64x(_Data);
91999199
#endif // ^^^ !defined(_WIN64) ^^^
92009200
}
@@ -9277,8 +9277,8 @@ namespace {
92779277
struct _Traits_8_sse : _Traits_sse {
92789278
static __m128i _Broadcast(const uint64_t _Data) noexcept {
92799279
#ifdef _WIN64
9280-
return _mm_shuffle_epi32(_mm_cvtsi64x_si128(_Data), _MM_SHUFFLE(1, 0, 1, 0));
9281-
#else // ^^^ defined(_WIN64) / !defined(_WIN64), workaround, _mm_cvtsi64x_si128 does not compile vvv
9280+
return _mm_shuffle_epi32(_mm_cvtsi64_si128(_Data), _MM_SHUFFLE(1, 0, 1, 0));
9281+
#else // ^^^ defined(_WIN64) / !defined(_WIN64), workaround, _mm_cvtsi64_si128 does not compile vvv
92829282
return _mm_set1_epi64x(_Data);
92839283
#endif // ^^^ !defined(_WIN64) ^^^
92849284
}

0 commit comments

Comments
 (0)