[Mlir-commits] [mlir] [MLIR][NVVM] Update Op verifiers to prevent ungraceful exits (PR #165677)

Durgadoss R llvmlistbot at llvm.org
Mon Nov 3 02:19:34 PST 2025


================
@@ -867,15 +867,20 @@ LogicalResult MmaOp::verify() {
 }
 
 LogicalResult ShflOp::verify() {
-  if (!(*this)->getAttrOfType<UnitAttr>("return_value_and_is_valid"))
-    return success();
   auto type = llvm::dyn_cast<LLVM::LLVMStructType>(getType());
-  auto elementType = (type && type.getBody().size() == 2)
-                         ? llvm::dyn_cast<IntegerType>(type.getBody()[1])
-                         : nullptr;
-  if (!elementType || elementType.getWidth() != 1)
-    return emitError("expected return type to be a two-element struct with "
-                     "i1 as the second element");
+
+  if ((*this)->getAttrOfType<UnitAttr>("return_value_and_is_valid")) {
+    auto predicateType = (type && type.getBody().size() == 2)
+                             ? llvm::dyn_cast<IntegerType>(type.getBody()[1])
+                             : nullptr;
+    if (!predicateType || predicateType.getWidth() != 1)
+      return emitOpError("expected return type to be a two-element struct with "
+                         "i1 as the second element");
+  } else {
+    if (type)
+      return emitOpError("\"return_value_and_is_valid\" attribute must be "
+                         "specified when returning the predicate");
----------------
durga4github wrote:

ok, It took me a while to fully comprehend this. I also looked at SHFL_INFO intrinsic generation to see what variants we generate.

Do we want something like below?

```
if (result is a struct-type) {
Type of (struct-elem[0]) should be Type of (val)
Type of (struct-elem[1]) should be i1
} else {
type of res and val should match.
}
```

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


More information about the Mlir-commits mailing list