[llvm] Add constant folding for llvm.experimental.cttz.elts #182324 (PR #182895)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 04:07:37 PST 2026
================
@@ -0,0 +1,69 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
+
+define i32 @cttz_elts_v4i1() {
+; CHECK-LABEL: @cttz_elts_v4i1(
+; CHECK-NEXT: ret i32 3
+;
+ %res = call i32 @llvm.experimental.cttz.elts.i32.v4i1(<4 x i1> <i1 false, i1 false, i1 false, i1 true>, i1 false)
----------------
lukel97 wrote:
> Is my interpretation correct in that even if the first lane is a non-zero, if the return type is too small it should still return a poison? For example would call i1 cttz.elts(<4 x i8> <1, 1, 1, 1>) return poison as well?
I think so, the LangRef says it needs to hold the maximum number of elements.
> Also, another part that has me confused is whether the return type is too small using max or unsigned max of type Ty
I think that example you provided is correct, the IR printer is just printing it as a signed integer but there's no notion of signed-ness in LLVM IR types. Interpreted as unsigned that's 3 which fits the max number of elements.
https://github.com/llvm/llvm-project/pull/182895
More information about the llvm-commits
mailing list