[Mlir-commits] [mlir] [mlir][spirv] Check output of getConstantInt (PR #140568)

Jakub Kuderski llvmlistbot at llvm.org
Mon Jun 2 13:13:39 PDT 2025


================
@@ -1061,12 +1061,22 @@ LogicalResult spirv::Deserializer::processCooperativeMatrixTypeKHR(
            << operands[2];
   }
 
-  unsigned rows = getConstantInt(operands[3]).getInt();
-  unsigned columns = getConstantInt(operands[4]).getInt();
+  IntegerAttr rowsAttr = getConstantInt(operands[3]);
+  IntegerAttr columnsAttr = getConstantInt(operands[4]);
+  IntegerAttr useAttr = getConstantInt(operands[5]);
+
+  if (!rowsAttr || !columnsAttr || !useAttr)
+    return emitError(
+               unknownLoc,
+               "OpTypeCooperativeMatrixKHR references undefined constant <id> ")
+           << (rowsAttr ? (columnsAttr ? operands[5] : operands[4])
+                        : operands[3]);
----------------
kuhar wrote:

Could you expand this into a few statements instead? Nested ternaries are not very readable

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


More information about the Mlir-commits mailing list