v128: A few optimizations (#8432)

This commit is contained in:
Eladash 2020-06-15 17:24:04 +03:00 committed by GitHub
parent 5777a1d426
commit 731d4330fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "types.h"
#include "util/endian.hpp"
@ -355,12 +355,12 @@ union alignas(16) v128
bool operator==(const v128& right) const
{
return _u64[0] == right._u64[0] && _u64[1] == right._u64[1];
return _mm_movemask_epi8(v128::eq32(*this, right).vi) == 0xffff;
}
bool operator!=(const v128& right) const
{
return _u64[0] != right._u64[0] || _u64[1] != right._u64[1];
return !operator==(right);
}
// result = (~left) & (right)
@ -371,8 +371,7 @@ union alignas(16) v128
void clear()
{
_u64[0] = 0;
_u64[1] = 0;
*this = {};
}
};
@ -403,7 +402,7 @@ inline v128 operator^(const v128& left, const v128& right)
inline v128 operator~(const v128& other)
{
return v128::from64(~other._u64[0], ~other._u64[1]);
return other ^ v128::from32p(UINT32_MAX); // XOR with ones
}
using stx::se_t;