Generic find_first_set_bit can use __builtin_ctz instead of __builtin_ffs

The former gives 0-based indexes, which is what our implementation returns,
making the "- 1" unnecessary.

Change-Id: I172ab5e06695be62e4a18d4fd0415b8314f5dc26
This commit is contained in:
Michael Sevakis 2012-02-04 18:08:17 -05:00
parent 1a083cdacc
commit 67dd4d6995

View file

@ -35,7 +35,8 @@ int find_first_set_bit(uint32_t val)
if (val == 0) if (val == 0)
return 32; return 32;
/* __builtin_ffs(l(l)): Returns one plus the index of the least significant /* __builtin_ctz[l[l]]: Returns the number of trailing 0-bits in x,
1-bit of x, or if x is zero, returns zero. */ * starting at the least significant bit position. If x is 0, the result
return __builtin_ffs(val) - 1; * is undefined. */
return __builtin_ctz(val);
} }