From: Alok Hota Date: Tue, 14 Aug 2018 17:36:00 +0000 (-0500) Subject: swr/rast: Flip BitScanReverse index calculation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=05e4ff33f5c717275e88844e67d0fc3dd12d9d2b;p=mesa.git swr/rast: Flip BitScanReverse index calculation The intrinsic returns the number of leading zeros, not the bit number of the first nonzero, so just flip it based on the mask size Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h index d685467906b..314d8184374 100644 --- a/src/gallium/drivers/swr/rasterizer/common/os.h +++ b/src/gallium/drivers/swr/rasterizer/common/os.h @@ -202,13 +202,13 @@ inline unsigned char _BitScanForward(unsigned int* Index, unsigned int Mask) inline unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask) { - *Index = __builtin_clz(Mask); + *Index = 63 - __builtin_clz(Mask); return (Mask != 0); } inline unsigned char _BitScanReverse(unsigned int* Index, unsigned int Mask) { - *Index = __builtin_clz(Mask); + *Index = 31 - __builtin_clz(Mask); return (Mask != 0); }