[clang] [clang] Introduce elementwise clz/ctz builtins (PR #131995)
Fraser Cormack via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 30 03:04:10 PDT 2025
frasercrmck wrote:
> > Also does this have the same maybe-defined-maybe-not-depending-on-target-preference as __builtin_clz? Can you document that explicitly if it is or not?
> > I've always hated that behavior and think it's absurd. My main hesitation is if we're doing something less confusing, could switch to match the llvm intrinsic name
>
> There _is_ currently target-specific zero-is-undef behaviour in this patch. On second thought I agree - I don't think we should be replicating that.
>
> @efriedma-quic, since you've already approved, would you object to having these builtins unconditionally have zero-is-undef behaviour? What do you think about renaming these builtins as something like `__builtin_elementwise_cttz` (`ctlz`) to avoid the conflation of behaviour with the GCC builtins?
Oh excuse me, there's currently no target-specific behaviour. I missed the `HasFallback` in
``` cpp
Value *ZeroUndef =
Builder.getInt1(HasFallback || getTarget().isCLZForZeroUndef());
```
So neither `__builtin_ctzg` or `__builtin_elementwise_ctz` currently have target-specific undef behaviour. Sorry about that, @arsenm.
https://github.com/llvm/llvm-project/pull/131995
More information about the cfe-commits
mailing list