[Mlir-commits] [mlir] [NFC][mlir][SPIR-V] Rename getUnaryOpResultType to getMatchingBoolType (PR #191773)
Arseniy Obolenskiy
llvmlistbot at llvm.org
Mon Apr 13 01:45:40 PDT 2026
https://github.com/aobolensk created https://github.com/llvm/llvm-project/pull/191773
The old name was misleading because this function is not specific to unary ops
suggested in https://github.com/llvm/llvm-project/pull/189099#discussion_r3051945317
>From 86179a397735d7703fe523f7ae38b81ac44e1032 Mon Sep 17 00:00:00 2001
From: Arseniy Obolenskiy <arseniy.obolenskiy at amd.com>
Date: Mon, 13 Apr 2026 10:20:14 +0200
Subject: [PATCH] [NFC][mlir][SPIR-V] Rename getUnaryOpResultType to
getMatchingBoolType
The old name was misleading because this function is not specific to unary ops
---
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td | 4 ++--
mlir/lib/Dialect/SPIRV/IR/SPIRVOpDefinition.cpp | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
index 9331fc576c7bd..179219042c882 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
@@ -27,7 +27,7 @@ class SPIRV_LogicalBinaryOp<string mnemonic, Type operandsType,
TypesMatchWith<"type of result to correspond to the `i1` "
"equivalent of the operand",
"operand1", "result",
- "getUnaryOpResultType($_self)"
+ "getMatchingBoolType($_self)"
>])> {
let assemblyFormat = "$operand1 `,` $operand2 `:` type($operand1) attr-dict";
}
@@ -41,7 +41,7 @@ class SPIRV_LogicalUnaryOp<string mnemonic, Type operandType,
TypesMatchWith<"type of result to correspond to the `i1` "
"equivalent of the operand",
"operand", "result",
- "getUnaryOpResultType($_self)"
+ "getMatchingBoolType($_self)"
>])> {
let assemblyFormat = "$operand `:` type($operand) attr-dict";
}
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOpDefinition.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOpDefinition.cpp
index ba69fa75cf2b8..b9075da95a617 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOpDefinition.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOpDefinition.cpp
@@ -49,8 +49,9 @@ static bool isDirectInModuleLikeOp(Operation *op) {
return op && op->hasTrait<OpTrait::SymbolTable>();
}
-/// Result of a logical op must be a scalar or vector of boolean type.
-static Type getUnaryOpResultType(Type operandType) {
+/// Returns a boolean scalar or vector type matching the shape of the given
+/// type. Scalar inputs yield i1, vector inputs yield vector<Nxi1>.
+static Type getMatchingBoolType(Type operandType) {
Builder builder(operandType.getContext());
Type resultType = builder.getIntegerType(1);
if (auto vecType = dyn_cast<VectorType>(operandType))
More information about the Mlir-commits
mailing list