[Mlir-commits] [mlir] [mlir][llvmir] Add SameOperandsAndResultType trait to LLVM_CountZerosIntrOp (PR #131133)

Letu Ren llvmlistbot at llvm.org
Thu Mar 13 05:50:50 PDT 2025


https://github.com/FantasqueX created https://github.com/llvm/llvm-project/pull/131133

According to https://llvm.org/docs/LangRef.html#llvm-ctlz-intrinsic and https://llvm.org/docs/LangRef.html#llvm-cttz-intrinsic, The return type of `llvm.intr.ctlz` and `llvm.intr.cttz` must match the first argument type.

>From 32e2cad5bc79cd376e317828b0f653844fa11567 Mon Sep 17 00:00:00 2001
From: Letu Ren <fantasquex at gmail.com>
Date: Thu, 13 Mar 2025 20:48:21 +0800
Subject: [PATCH] [mlir][llvmir] Add SameOperandsAndResultType trait to
 LLVM_CountZerosIntrOp

---
 mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index e80745781f566..37193f384174e 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -86,7 +86,7 @@ class LLVM_TernarySameArgsIntrOpF<string func, list<Trait> traits = []> :
 
 class LLVM_CountZerosIntrOp<string func, list<Trait> traits = []> :
     LLVM_OneResultIntrOp<func, [], [0],
-           !listconcat([Pure], traits),
+           !listconcat([Pure, SameOperandsAndResultType], traits),
             /*requiresFastmath=*/0,
             /*immArgPositions=*/[1], /*immArgAttrNames=*/["is_zero_poison"]> {
   let arguments = (ins LLVM_ScalarOrVectorOf<AnySignlessInteger>:$in,



More information about the Mlir-commits mailing list