[clang] [clang] Introduce elementwise ctlz/cttz builtins (PR #131995)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 5 06:47:43 PDT 2025


arsenm wrote:

I'd view assertively stating its undefined behavior as a move away from the status quo.  For `__builtin_clz`, GCC states `the result is undefined`. Clang appears to not have separate documentation for that exact spelling. It does have documentation for `__builtin_clzg`, which has the undefined behavior phrasing. 

> We don't currently have a definition of what it means to "use" a value in a way that would cause undefined behavior with poison.

Which means stating it produces undefined behavior less accurate?

> If you have some plan to use this notion of "undefined value" for something other than ctlz/cttz,

There are a handful of other intrinsics which are documented as returning `freeze poison` 

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


More information about the cfe-commits mailing list