mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Merge pull request #11927 from Jamiras/sse2_msc_find_change
fix rewind crash on MSVC build when using SSE2
This commit is contained in:
commit
a213c2dcdf
@ -63,20 +63,34 @@ static INLINE int compat_ctz(unsigned x)
|
|||||||
return __builtin_ctz(x);
|
return __builtin_ctz(x);
|
||||||
#elif _MSC_VER >= 1400 && !defined(_XBOX) && !defined(__WINRT__)
|
#elif _MSC_VER >= 1400 && !defined(_XBOX) && !defined(__WINRT__)
|
||||||
unsigned long r = 0;
|
unsigned long r = 0;
|
||||||
_BitScanReverse((unsigned long*)&r, x);
|
_BitScanForward((unsigned long*)&r, x);
|
||||||
return (int)r;
|
return (int)r;
|
||||||
#else
|
#else
|
||||||
/* Only checks at nibble granularity,
|
int count = 0;
|
||||||
* because that's what we need. */
|
if (!(x & 0xffff))
|
||||||
if (x & 0x000f)
|
{
|
||||||
return 0;
|
x >>= 16;
|
||||||
if (x & 0x00f0)
|
count |= 16;
|
||||||
return 4;
|
}
|
||||||
if (x & 0x0f00)
|
if (!(x & 0xff))
|
||||||
return 8;
|
{
|
||||||
if (x & 0xf000)
|
x >>= 8;
|
||||||
return 12;
|
count |= 8;
|
||||||
return 16;
|
}
|
||||||
|
if (!(x & 0xf))
|
||||||
|
{
|
||||||
|
x >>= 4;
|
||||||
|
count |= 4;
|
||||||
|
}
|
||||||
|
if (!(x & 0x3))
|
||||||
|
{
|
||||||
|
x >>= 2;
|
||||||
|
count |= 2;
|
||||||
|
}
|
||||||
|
if (!(x & 0x1))
|
||||||
|
count |= 1;
|
||||||
|
|
||||||
|
return count;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,14 +94,17 @@ static size_t find_change(const uint16_t *a, const uint16_t *b)
|
|||||||
{
|
{
|
||||||
__m128i v0 = _mm_loadu_si128(a128);
|
__m128i v0 = _mm_loadu_si128(a128);
|
||||||
__m128i v1 = _mm_loadu_si128(b128);
|
__m128i v1 = _mm_loadu_si128(b128);
|
||||||
__m128i c = _mm_cmpeq_epi32(v0, v1);
|
__m128i c = _mm_cmpeq_epi8(v0, v1);
|
||||||
uint32_t mask = _mm_movemask_epi8(c);
|
uint32_t mask = _mm_movemask_epi8(c);
|
||||||
|
|
||||||
if (mask != 0xffff) /* Something has changed, figure out where. */
|
if (mask != 0xffff) /* Something has changed, figure out where. */
|
||||||
{
|
{
|
||||||
|
/* calculate the real offset to the differing byte */
|
||||||
size_t ret = (((uint8_t*)a128 - (uint8_t*)a) |
|
size_t ret = (((uint8_t*)a128 - (uint8_t*)a) |
|
||||||
(compat_ctz(~mask))) >> 1;
|
(compat_ctz(~mask)));
|
||||||
return ret | (a[ret] == b[ret]);
|
|
||||||
|
/* and convert that to the uint16_t offset */
|
||||||
|
return (ret >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
a128++;
|
a128++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user