This patch adds support for calculating ctz/clz of unsigned short.
The idea is to use builtin_clzs/builtin_ctzs when available
or fallback to use unsigned int version with additional bit number
manipulations.
Details
- Reviewers
gchatelet
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
What would be the use case here?
I'd rather keep these functions to what's strictly required. The smallest the code base, the better.
@gchatelet Hi, this is intended to be used in https://reviews.llvm.org/D136490. SSE2 movemask operations on byte vectors will give 16-bit masks and we want to use that to locate available bucket slot in hash table.
I see, thx for the context.
I would like to get some tests as well.
Also __has_builtin only exists from gcc 10.0 on. You first need to check that it is defined first.
libc/src/__support/builtin_wrappers.h | ||
---|---|---|
50 | sizeof is a function not a template, these should be parentheses and not brackets. | |
68 | This is supposed to be __builtin_ctz right? |
@SchrodingerZhu are you planning to land this patch?
If so you'd need to use LLVM_LIBC_HAS_BUILTIN from libc/src/__support/compiler_features.h.
sizeof is a function not a template, these should be parentheses and not brackets.