From 05e4ff33f5c717275e88844e67d0fc3dd12d9d2b Mon Sep 17 00:00:00 2001 From: Alok Hota Date: Tue, 14 Aug 2018 12:36:00 -0500 Subject: [PATCH] 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 --- src/gallium/drivers/swr/rasterizer/common/os.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } -- 2.30.2