@@ -27,13 +27,14 @@ namespace simd {
2727 really_inline operator __m256i&() { return this ->value ; }
2828
2929 // Bit operations
30- really_inline Child operator |(const Child other) const { return _mm256_or_si256 (*this , other); }
31- really_inline Child operator &(const Child other) const { return _mm256_and_si256 (*this , other); }
32- really_inline Child operator ^(const Child other) const { return _mm256_xor_si256 (*this , other); }
33- really_inline Child bit_andnot (const Child other) const { return _mm256_andnot_si256 (other, *this ); }
34- really_inline Child& operator |=(const Child other) { auto this_cast = (Child*)this ; *this_cast = *this_cast | other; return *this_cast; }
35- really_inline Child& operator &=(const Child other) { auto this_cast = (Child*)this ; *this_cast = *this_cast & other; return *this_cast; }
36- really_inline Child& operator ^=(const Child other) { auto this_cast = (Child*)this ; *this_cast = *this_cast ^ other; return *this_cast; }
30+ really_inline Child operator |(const Child& other) const { return _mm256_or_si256 (*this , other); }
31+ really_inline Child operator &(const Child& other) const { return _mm256_and_si256 (*this , other); }
32+ really_inline Child operator ^(const Child& other) const { return _mm256_xor_si256 (*this , other); }
33+ really_inline Child bit_andnot (const Child& other) const { return _mm256_andnot_si256 (other, *this ); }
34+ really_inline Child& operator =(const Child& other) const { value = other.value ; return *this ; }
35+ really_inline Child& operator |=(const Child& other) { this ->value = _mm256_or_si256 (this ->value , other.value ); return (Child& )*this ; }
36+ really_inline Child& operator &=(const Child& other) { this ->value = _mm256_and_si256 (this ->value , other.value ); return (Child& )*this ; }
37+ really_inline Child& operator ^=(const Child& other) { this ->value = _mm256_xor_si256 (this ->value , other.value ); return (Child& )*this ; }
3738 };
3839
3940 // Forward-declared so they can be used by splat and friends.
@@ -48,12 +49,12 @@ namespace simd {
4849 really_inline base8 () : base<simd8<T>>() {}
4950 really_inline base8 (const __m256i _value) : base<simd8<T>>(_value) {}
5051
51- really_inline Mask operator ==(const simd8<T> other) const { return _mm256_cmpeq_epi8 (*this , other); }
52+ really_inline Mask operator ==(const simd8<T>& other) const { return _mm256_cmpeq_epi8 (*this , other); }
5253
5354 static const int SIZE = sizeof (base<T>::value);
5455
5556 template <int N=1 >
56- really_inline simd8<T> prev (const simd8<T> prev_chunk) const {
57+ really_inline simd8<T> prev (const simd8<T>& prev_chunk) const {
5758 return _mm256_alignr_epi8 (*this , _mm256_permute2x128_si256 (prev_chunk, *this , 0x21 ), 16 - N);
5859 }
5960 };
@@ -224,6 +225,7 @@ namespace simd {
224225 template <>
225226 struct simd8 <uint8_t >: base8_numeric<uint8_t > {
226227 really_inline simd8 () : base8_numeric<uint8_t>() {}
228+
227229 really_inline simd8 (const __m256i _value) : base8_numeric<uint8_t>(_value) {}
228230 // Splat constructor
229231 really_inline simd8 (uint8_t _value) : simd8(splat(_value)) {}
@@ -255,31 +257,31 @@ namespace simd {
255257 }
256258
257259 // Saturated math
258- really_inline simd8<uint8_t > saturating_add (const simd8<uint8_t > other) const { return _mm256_adds_epu8 (*this , other); }
259- really_inline simd8<uint8_t > saturating_sub (const simd8<uint8_t > other) const { return _mm256_subs_epu8 (*this , other); }
260+ really_inline simd8<uint8_t > saturating_add (const simd8<uint8_t >& other) const { return _mm256_adds_epu8 (*this , other); }
261+ really_inline simd8<uint8_t > saturating_sub (const simd8<uint8_t >& other) const { return _mm256_subs_epu8 (*this , other); }
260262
261263 // Order-specific operations
262- really_inline simd8<uint8_t > max (const simd8<uint8_t > other) const { return _mm256_max_epu8 (*this , other); }
263- really_inline simd8<uint8_t > min (const simd8<uint8_t > other) const { return _mm256_min_epu8 (other, *this ); }
264+ really_inline simd8<uint8_t > max (const simd8<uint8_t >& other) const { return _mm256_max_epu8 (*this , other); }
265+ really_inline simd8<uint8_t > min (const simd8<uint8_t >& other) const { return _mm256_min_epu8 (other, *this ); }
264266 // Same as >, but only guarantees true is nonzero (< guarantees true = -1)
265- really_inline simd8<uint8_t > gt_bits (const simd8<uint8_t > other) const { return this ->saturating_sub (other); }
267+ really_inline simd8<uint8_t > gt_bits (const simd8<uint8_t >& other) const { return this ->saturating_sub (other); }
266268 // Same as <, but only guarantees true is nonzero (< guarantees true = -1)
267- really_inline simd8<uint8_t > lt_bits (const simd8<uint8_t > other) const { return other.saturating_sub (*this ); }
268- really_inline simd8<bool > operator <=(const simd8<uint8_t > other) const { return other.max (*this ) == other; }
269- really_inline simd8<bool > operator >=(const simd8<uint8_t > other) const { return other.min (*this ) == other; }
270- really_inline simd8<bool > operator >(const simd8<uint8_t > other) const { return this ->gt_bits (other).any_bits_set (); }
271- really_inline simd8<bool > operator <(const simd8<uint8_t > other) const { return this ->lt_bits (other).any_bits_set (); }
269+ really_inline simd8<uint8_t > lt_bits (const simd8<uint8_t >& other) const { return other.saturating_sub (*this ); }
270+ really_inline simd8<bool > operator <=(const simd8<uint8_t >& other) const { return other.max (*this ) == other; }
271+ really_inline simd8<bool > operator >=(const simd8<uint8_t >& other) const { return other.min (*this ) == other; }
272+ really_inline simd8<bool > operator >(const simd8<uint8_t >& other) const { return this ->gt_bits (other).any_bits_set (); }
273+ really_inline simd8<bool > operator <(const simd8<uint8_t >& other) const { return this ->lt_bits (other).any_bits_set (); }
272274
273275 // Bit-specific operations
274276 really_inline simd8<bool > bits_not_set () const { return *this == uint8_t (0 ); }
275- really_inline simd8<bool > bits_not_set (simd8<uint8_t > bits) const { return (*this & bits).bits_not_set (); }
277+ really_inline simd8<bool > bits_not_set (simd8<uint8_t >& bits) const { return (*this & bits).bits_not_set (); }
276278 really_inline simd8<bool > any_bits_set () const { return ~this ->bits_not_set (); }
277- really_inline simd8<bool > any_bits_set (simd8<uint8_t > bits) const { return ~this ->bits_not_set (bits); }
279+ really_inline simd8<bool > any_bits_set (simd8<uint8_t >& bits) const { return ~this ->bits_not_set (bits); }
278280 really_inline bool is_ascii () const { return _mm256_movemask_epi8 (*this ) == 0 ; }
279281 really_inline bool bits_not_set_anywhere () const { return _mm256_testz_si256 (*this , *this ); }
280282 really_inline bool any_bits_set_anywhere () const { return !bits_not_set_anywhere (); }
281- really_inline bool bits_not_set_anywhere (simd8<uint8_t > bits) const { return _mm256_testz_si256 (*this , bits); }
282- really_inline bool any_bits_set_anywhere (simd8<uint8_t > bits) const { return !bits_not_set_anywhere (bits); }
283+ really_inline bool bits_not_set_anywhere (simd8<uint8_t >& bits) const { return _mm256_testz_si256 (*this , bits); }
284+ really_inline bool any_bits_set_anywhere (simd8<uint8_t >& bits) const { return !bits_not_set_anywhere (bits); }
283285 template <int N>
284286 really_inline simd8<uint8_t > shr () const { return simd8<uint8_t >(_mm256_srli_epi16 (*this , N)) & uint8_t (0xFFu >> N); }
285287 template <int N>
@@ -297,7 +299,7 @@ namespace simd {
297299 const simd8<T> chunks[NUM_CHUNKS ];
298300
299301 simd8x64 (const simd8x64<T>& o) = delete ; // no copy allowed
300- simd8x64<T>& operator =(const simd8<T> other) = delete ; // no assignment allowed
302+ simd8x64<T>& operator =(const simd8<T>& other) = delete ; // no assignment allowed
301303 simd8x64 () = delete ; // no default constructor allowed
302304
303305 really_inline simd8x64 (const simd8<T> chunk0, const simd8<T> chunk1) : chunks{chunk0, chunk1} {}
0 commit comments