@@ -920,10 +920,7 @@ class vbool16 {
920920
921921private:
922922 // The actual data representation
923- union {
924- simd_t m_simd;
925- uint16_t m_bits;
926- };
923+ simd_t m_simd;
927924};
928925
929926
@@ -3920,19 +3917,15 @@ OIIO_FORCEINLINE bool none (const vbool8& v) { return reduce_or(v) == false; }
39203917
39213918OIIO_FORCEINLINE int vbool16::operator [] (int i) const {
39223919 OIIO_DASSERT (i >= 0 && i < elements);
3923- #if OIIO_SIMD_AVX >= 512
3924- return (int (m_simd) >> i) & 1 ;
3925- #else
3926- return (m_bits >> i) & 1 ;
3927- #endif
3920+ return (static_cast <uint16_t >(m_simd) >> i) & 1 ;
39283921}
39293922
39303923OIIO_FORCEINLINE void vbool16::setcomp (int i, bool value) {
39313924 OIIO_DASSERT (i >= 0 && i < elements);
3932- int bits = m_bits ;
3925+ int bits = static_cast < uint16_t >(m_simd) ;
39333926 bits &= (0xffff ^ (1 <<i));
39343927 bits |= (int (value)<<i);
3935- m_bits = bits;
3928+ m_simd = static_cast < simd_t >( bits) ;
39363929}
39373930
39383931
@@ -4015,11 +4008,7 @@ OIIO_FORCEINLINE const vbool16& vbool16::operator= (const vbool16 & other) {
40154008
40164009
40174010OIIO_FORCEINLINE int vbool16::bitmask () const {
4018- #if OIIO_SIMD_AVX >= 512
4019- return int (m_simd);
4020- #else
4021- return int (m_bits);
4022- #endif
4011+ return static_cast <int >(m_simd);
40234012}
40244013
40254014
@@ -4038,13 +4027,13 @@ OIIO_FORCEINLINE const vbool16 vbool16::True () {
40384027
40394028
40404029OIIO_FORCEINLINE void vbool16::store (bool *values) const {
4041- SIMD_DO (values[i] = m_bits & (1 <<i));
4030+ SIMD_DO (values[i] = m_simd & (1 <<i));
40424031}
40434032
40444033OIIO_FORCEINLINE void vbool16::store (bool *values, int n) const {
40454034 OIIO_DASSERT (n >= 0 && n <= elements);
40464035 for (int i = 0 ; i < n; ++i)
4047- values[i] = m_bits & (1 <<i);
4036+ values[i] = m_simd & (1 <<i);
40484037}
40494038
40504039
@@ -4070,31 +4059,31 @@ OIIO_FORCEINLINE vbool16 operator! (const vbool16 & a) {
40704059#if OIIO_SIMD_AVX >= 512
40714060 return _mm512_knot (a.simd ());
40724061#else
4073- return vbool16 (a.m_bits ^ 0xffff );
4062+ return vbool16 (a.m_simd ^ 0xffff );
40744063#endif
40754064}
40764065
40774066OIIO_FORCEINLINE vbool16 operator & (const vbool16 & a, const vbool16 & b) {
40784067#if OIIO_SIMD_AVX >= 512
40794068 return _mm512_kand (a.simd (), b.simd ());
40804069#else
4081- return vbool16 (a.m_bits & b.m_bits );
4070+ return vbool16 (a.m_simd & b.m_simd );
40824071#endif
40834072}
40844073
40854074OIIO_FORCEINLINE vbool16 operator | (const vbool16 & a, const vbool16 & b) {
40864075#if OIIO_SIMD_AVX >= 512
40874076 return _mm512_kor (a.simd (), b.simd ());
40884077#else
4089- return vbool16 (a.m_bits | b.m_bits );
4078+ return vbool16 (a.m_simd | b.m_simd );
40904079#endif
40914080}
40924081
40934082OIIO_FORCEINLINE vbool16 operator ^ (const vbool16& a, const vbool16& b) {
40944083#if OIIO_SIMD_AVX >= 512
40954084 return _mm512_kxor (a.simd (), b.simd ());
40964085#else
4097- return vbool16 (a.m_bits ^ b.m_bits );
4086+ return vbool16 (a.m_simd ^ b.m_simd );
40984087#endif
40994088}
41004089
@@ -4121,15 +4110,15 @@ OIIO_FORCEINLINE vbool16 operator== (const vbool16 & a, const vbool16 & b) {
41214110#if OIIO_SIMD_AVX >= 512
41224111 return _mm512_kxnor (a.simd (), b.simd ());
41234112#else
4124- return vbool16 (!(a.m_bits ^ b.m_bits ));
4113+ return vbool16 (!(a.m_simd ^ b.m_simd ));
41254114#endif
41264115}
41274116
41284117OIIO_FORCEINLINE vbool16 operator != (const vbool16 & a, const vbool16 & b) {
41294118#if OIIO_SIMD_AVX >= 512
41304119 return _mm512_kxor (a.simd (), b.simd ());
41314120#else
4132- return vbool16 (a.m_bits ^ b.m_bits );
4121+ return vbool16 (a.m_simd ^ b.m_simd );
41334122#endif
41344123}
41354124
0 commit comments