[Mlir-commits] [mlir] [NFC][mlir][SPIR-V] Rename getUnaryOpResultType to getMatchingBoolType (PR #191773)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 13 01:46:13 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-spirv

Author: Arseniy Obolenskiy (aobolensk)

<details>
<summary>Changes</summary>

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 

---
Full diff: https://github.com/llvm/llvm-project/pull/191773.diff


2 Files Affected:

- (modified) mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td (+2-2) 
- (modified) mlir/lib/Dialect/SPIRV/IR/SPIRVOpDefinition.cpp (+3-2) 


``````````diff
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))

``````````

</details>


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


More information about the Mlir-commits mailing list