Mesa (master): swr: fix win32 intrinsics
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Mar 15 13:26:42 UTC 2021
Module: Mesa
Branch: master
Commit: 0e8cdea6d949c334e8c59cff136d241c3ca32fba
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e8cdea6d949c334e8c59cff136d241c3ca32fba
Author: Michel Zou <xantares09 at hotmail.com>
Date: Wed Mar 10 21:25:05 2021 +0100
swr: fix win32 intrinsics
The doc doesnt mention Index is altered when mask is null.
This is consistent with both llvm & migw implementations.
Reviewed-by: Jan Zielinski <jan.zielinski at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9502>
---
src/gallium/drivers/swr/rasterizer/common/os.h | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h
index b949625ae73..ed42e1eb79e 100644
--- a/src/gallium/drivers/swr/rasterizer/common/os.h
+++ b/src/gallium/drivers/swr/rasterizer/common/os.h
@@ -109,6 +109,8 @@ static inline void AlignedFree(void* p)
extern "C" {
inline unsigned char _BitScanForward64(unsigned long* Index, uint64_t Mask)
{
+ if (Mask == 0)
+ return 0;
#ifdef __GNUC__
*Index = __builtin_ctzll(Mask);
#else
@@ -117,11 +119,13 @@ inline unsigned char _BitScanForward64(unsigned long* Index, uint64_t Mask)
if ((1ULL << i) & Mask)
*Index = i;
#endif
- return (Mask != 0);
+ return 1;
}
inline unsigned char _BitScanReverse64(unsigned long* Index, uint64_t Mask)
{
+ if (Mask == 0)
+ return 0;
#ifdef __GNUC__
*Index = 63 - __builtin_clzll(Mask);
#else
@@ -130,7 +134,7 @@ inline unsigned char _BitScanReverse64(unsigned long* Index, uint64_t Mask)
if ((1ULL << i) & Mask)
*Index = i;
#endif
- return (Mask != 0);
+ return 1;
}
}
#endif
@@ -230,26 +234,34 @@ static INLINE void _mm256_storeu2_m128i(__m128i* hi, __m128i* lo, __m256i a)
inline unsigned char _BitScanForward64(unsigned long* Index, uint64_t Mask)
{
+ if (Mask == 0)
+ return 0;
*Index = __builtin_ctzll(Mask);
- return (Mask != 0);
+ return 1;
}
inline unsigned char _BitScanForward(unsigned long* Index, uint32_t Mask)
{
+ if (Mask == 0)
+ return 0;
*Index = __builtin_ctz(Mask);
- return (Mask != 0);
+ return 1;
}
inline unsigned char _BitScanReverse64(unsigned long* Index, uint64_t Mask)
{
+ if (Mask == 0)
+ return 0;
*Index = 63 - __builtin_clzll(Mask);
- return (Mask != 0);
+ return 1;
}
inline unsigned char _BitScanReverse(unsigned long* Index, uint32_t Mask)
{
+ if (Mask == 0)
+ return 0;
*Index = 31 - __builtin_clz(Mask);
- return (Mask != 0);
+ return 1;
}
inline void* AlignedMalloc(size_t size, size_t alignment)
More information about the mesa-commit
mailing list