Skip to content

Commit 6799d7e

Browse files
ahmedarif193tkreuzer
authored andcommitted
[ARM64][SDK] Address intrinsic review feedback
1 parent 658328c commit 6799d7e

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎sdk/include/vcruntime/mingw32/intrin_arm64.h‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ __INTRIN_INLINE unsigned char _BitScanReverse(unsigned long *Index, unsigned lon
104104
if (!Mask)
105105
return 0;
106106

107-
*Index = (sizeof(Mask) * 8 - 1) - __builtin_clzl(Mask);
107+
*Index = 31 - __builtin_clzl(Mask);
108108
return 1;
109109
}
110110
#endif
@@ -407,16 +407,16 @@ __INTRIN_INLINE void __nop(void)
407407
#if !HAS_BUILTIN(_bittest)
408408
__INTRIN_INLINE unsigned char _bittest(const long *a, long b)
409409
{
410-
return (a[b / (sizeof(long) * 8)] >> (b % (sizeof(long) * 8))) & 1;
410+
return (a[b / 32] >> (b % 32)) & 1;
411411
}
412412
#endif
413413

414414
#if !HAS_BUILTIN(_bittestandset)
415415
__INTRIN_INLINE unsigned char _bittestandset(long *a, long b)
416416
{
417-
long bit = 1L << (b % (sizeof(long) * 8));
418-
long *ptr = &a[b / (sizeof(long) * 8)];
419-
unsigned char retval = (*ptr >> (b % (sizeof(long) * 8))) & 1;
417+
long bit = 1L << (b % 32);
418+
long *ptr = &a[b / 32];
419+
unsigned char retval = (*ptr >> (b % 32)) & 1;
420420
*ptr |= bit;
421421
return retval;
422422
}
@@ -425,9 +425,9 @@ __INTRIN_INLINE unsigned char _bittestandset(long *a, long b)
425425
#if !HAS_BUILTIN(_bittestandreset)
426426
__INTRIN_INLINE unsigned char _bittestandreset(long *a, long b)
427427
{
428-
long bit = 1L << (b % (sizeof(long) * 8));
429-
long *ptr = &a[b / (sizeof(long) * 8)];
430-
unsigned char retval = (*ptr >> (b % (sizeof(long) * 8))) & 1;
428+
long bit = 1L << (b % 32);
429+
long *ptr = &a[b / 32];
430+
unsigned char retval = (*ptr >> (b % 32)) & 1;
431431
*ptr &= ~bit;
432432
return retval;
433433
}
@@ -436,9 +436,9 @@ __INTRIN_INLINE unsigned char _bittestandreset(long *a, long b)
436436
#if !HAS_BUILTIN(_bittestandcomplement)
437437
__INTRIN_INLINE unsigned char _bittestandcomplement(long *a, long b)
438438
{
439-
long bit = 1L << (b % (sizeof(long) * 8));
440-
long *ptr = &a[b / (sizeof(long) * 8)];
441-
unsigned char retval = (*ptr >> (b % (sizeof(long) * 8))) & 1;
439+
long bit = 1L << (b % 32);
440+
long *ptr = &a[b / 32];
441+
unsigned char retval = (*ptr >> (b % 32)) & 1;
442442
*ptr ^= bit;
443443
return retval;
444444
}

0 commit comments

Comments
 (0)