From f945eea569993a4e5ed953f4573e6eab785f309f Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 15 May 2020 12:16:05 -0400 Subject: nonmoving: Optimise log2_ceil --- rts/sm/NonMoving.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'rts') diff --git a/rts/sm/NonMoving.c b/rts/sm/NonMoving.c index 99c639fb30..09945ce776 100644 --- a/rts/sm/NonMoving.c +++ b/rts/sm/NonMoving.c @@ -586,15 +586,9 @@ static struct NonmovingSegment *nonmovingAllocSegment(uint32_t node) return ret; } -static inline unsigned long log2_floor(unsigned long x) -{ - return sizeof(unsigned long)*8 - 1 - __builtin_clzl(x); -} - static inline unsigned long log2_ceil(unsigned long x) { - unsigned long log = log2_floor(x); - return (x - (1 << log)) ? log + 1 : log; + return (sizeof(unsigned long)*8) - __builtin_clzl(x-1); } // Advance a segment's next_free pointer. Returns true if segment if full. -- cgit v1.2.1