[Mlir-commits] [mlir] [mlir][AMDGPU] Avoid verifier crash in DPPOp on vector operand types (PR #178887)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jan 30 05:25:28 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Ayush Kumar Gaur (Ayush3941)
<details>
<summary>Changes</summary>
### whats the problem
mlir-opt could crash while verifying amdgpu.dpp when its operands had vector
types, such as ARM SME tile vectors produced by arm_sme.get_tile.
The crash occurred during IR verification, before any lowering or passes ran.
### why it happens
DPPOp::verify() called Type::getIntOrFloatBitWidth() on the operand type.
When the operand was a VectorType, this hit an assertion because only scalar
integer and float types have a bitwidth.
### whats the fix
Query the bitwidth on the element type using getElementTypeOrSelf() instead of
the container type.
Add a regression test to ensure amdgpu.dpp verification no longer asserts on
vector operand types.
Fixes #<!-- -->178128
---
Full diff: https://github.com/llvm/llvm-project/pull/178887.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp (+2-2)
- (added) mlir/test/Dialect/AMDGPU/dpp-verify-no-assert-on-vectors.mlir (+13)
``````````diff
diff --git a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
index 87a813a31608d..c39ae9fc14831 100644
--- a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
+++ b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
@@ -675,11 +675,11 @@ LogicalResult SparseMFMAOp::verify() {
//===----------------------------------------------------------------------===//
LogicalResult DPPOp::verify() {
Type srcType = getSrc().getType();
- if (srcType.getIntOrFloatBitWidth() > 64) {
+ Type elemType = getElementTypeOrSelf(srcType);
+ if (elemType.getIntOrFloatBitWidth() > 64) {
return emitOpError("integer and floating point types larger than 64 bits "
"are not supported");
}
-
DPPPerm kind = getKind();
Attribute permArgument = getPermArgument().value_or(Attribute{});
diff --git a/mlir/test/Dialect/AMDGPU/dpp-verify-no-assert-on-vectors.mlir b/mlir/test/Dialect/AMDGPU/dpp-verify-no-assert-on-vectors.mlir
new file mode 100644
index 0000000000000..c2d712cc3d004
--- /dev/null
+++ b/mlir/test/Dialect/AMDGPU/dpp-verify-no-assert-on-vectors.mlir
@@ -0,0 +1,13 @@
+// RUN: mlir-opt %s -verify-each
+
+// DPPOp verifier must not assert when src type is a
+// vector (e.g. ARM SME tile vectors).
+
+module {
+ func.func @main() {
+ %tile = arm_sme.get_tile : vector<[16]x[16]xi8>
+ %pop = math.ctpop %tile : vector<[16]x[16]xi8>
+ %r = amdgpu.dpp %pop %tile row_shl(1 : i32) : vector<[16]x[16]xi8>
+ return
+ }
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/178887
More information about the Mlir-commits
mailing list