[clang] [clang] Introduce elementwise clz/ctz builtins (PR #131995)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 30 02:42:15 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?

https://github.com/llvm/llvm-project/pull/131995


More information about the cfe-commits mailing list