[llvm] [SelectionDAG] Add CTTZ_ELTS[_ZERO_POISON] nodes. NFCI (PR #185600)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 03:02:21 PDT 2026


================
@@ -1577,6 +1577,11 @@ enum NodeType {
   /// Output: Output Chain
   EXPERIMENTAL_VECTOR_HISTOGRAM,
 
+  /// The `llvm.experimental.cttz.elts` intrinsic. Has a single i1 vector
+  /// operand.
----------------
lukel97 wrote:

> Do we guarantee that the return type is large enough to cover all counts (i.e. i8 CTTZ_ELTS( v1024i1) is illegal?) - if so mention that.

This is a whole can of worms that I was hoping to avoid in this PR, but yeah the langref does enforce the width of the result type:

> The return type must also be an integer type which is wide enough to hold the maximum number of elements of the source vector. The behavior of this intrinsic is undefined if the return type is not wide enough for the number of elements in the input vector.

But it's not clear to me if this should be statically enforced by the verifier failure or just be poison. 

In either case, because vscale doesn't have any upper bound by default, every use of cttz.elts with a scalable vector that doesn't set the vscale_range attribute is undefined. There's a good few codegen tests in tree that hit this so they should be fixed separately. 

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


More information about the llvm-commits mailing list