Index: libcxx/include/experimental/simd =================================================================== --- libcxx/include/experimental/simd +++ libcxx/include/experimental/simd @@ -1219,6 +1219,11 @@ return *this; } + template + __simd_reference operator=(__simd_reference<_Vp, _Up, _Abi>&& __ref) && { + return std::move(*this) = _Vp(__ref); + } + __simd_reference operator++() && { return std::move(*this) = __ptr_->__get(__index_) + 1; } @@ -1288,6 +1293,22 @@ return std::move(*this) = __from_value_type(__ptr_->__get(__index_) ^ __val); } + + friend void swap(__simd_reference&& a, __simd_reference&& b) noexcept { + _Vp __val = std::move(b); + std::move(b) = std::move(a); + std::move(a) = __val; + } + + friend void swap(_Vp& a, __simd_reference&& b) noexcept { + swap(std::move(b), a); + } + + friend void swap(__simd_reference&& a, _Vp& b) noexcept { + _Vp __val = b; + b = std::move(a); + std::move(a) = __val; + } }; template Index: libcxx/test/std/experimental/simd/simd.access/default.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.access/default.pass.cpp +++ libcxx/test/std/experimental/simd/simd.access/default.pass.cpp @@ -77,6 +77,12 @@ assert(c[1] == 42); } + { + auto c = a; + c[0] = b[0]; + assert(c[0] == 4); + assert(c[1] == 42); + } { auto c = a; c[0] += b[0]; @@ -137,7 +143,30 @@ assert(c[0] == (42 ^ 4)); assert(c[1] == 42); } - + { + auto aa = a, bb = b; + swap(aa[0], bb[0]); + assert(aa[0] == 4); + assert(bb[0] == 42); + assert(aa[1] == 42); + assert(bb[1] == 4); + } + { + auto c = a; + int d = 4; + swap(c[0], d); + assert(c[0] == 4); + assert(d == 42); + assert(c[1] == 42); + } + { + auto c = a; + int d = 4; + swap(d, c[0]); + assert(c[0] == 4); + assert(d == 42); + assert(c[1] == 42); + } { auto c = a; (void)(a[0] + (c[0] += a[0])); Index: libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp =================================================================== --- libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp +++ libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp @@ -76,6 +76,12 @@ assert(bool(c[1]) == false); } + { + auto c = a; + c[0] = b[0]; + assert(bool(c[0]) == true); + assert(bool(c[1]) == false); + } { auto c = a; c[0] += b[0]; @@ -136,6 +142,30 @@ assert(bool(c[0]) == true); assert(bool(c[1]) == false); } + { + auto aa = a, bb = b; + swap(aa[0], bb[0]); + assert(aa[0] == true); + assert(bb[0] == false); + assert(aa[1] == false); + assert(bb[1] == true); + } + { + auto c = a; + bool d = true; + swap(c[0], d); + assert(c[0] == true); + assert(d == false); + assert(c[1] == false); + } + { + auto c = a; + bool d = true; + swap(d, c[0]); + assert(c[0] == true); + assert(d == false); + assert(c[1] == false); + } { auto c = a;