[Mlir-commits] [mlir] c381180 - [mlir][AMDGPU] Avoid verifier crash in DPPOp on vector operand types (#178887)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Feb 7 05:25:07 PST 2026
Author: Ayush Kumar Gaur
Date: 2026-02-07T08:25:03-05:00
New Revision: c3811805369be90f7fdac4c46e6bcc24019748dd
URL: https://github.com/llvm/llvm-project/commit/c3811805369be90f7fdac4c46e6bcc24019748dd
DIFF: https://github.com/llvm/llvm-project/commit/c3811805369be90f7fdac4c46e6bcc24019748dd.diff
LOG: [mlir][AMDGPU] Avoid verifier crash in DPPOp on vector operand types (#178887)
### 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
Added:
Modified:
mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPUOps.td
mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
mlir/test/Dialect/AMDGPU/invalid.mlir
mlir/test/Dialect/AMDGPU/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPUOps.td b/mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPUOps.td
index 6042a958a2b3b..fd1729fa171de 100644
--- a/mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPUOps.td
+++ b/mlir/include/mlir/Dialect/AMDGPU/IR/AMDGPUOps.td
@@ -33,6 +33,17 @@ def AnyIntegerOrFloat : AnyTypeOf<[AnySignlessInteger, AnyFloat], "Integer or Fl
def AnyIntegerOrFloatOr1DVector :
AnyTypeOf<[AnyIntegerOrFloat, FixedVectorOfRankAndType<[1], [AnyIntegerOrFloat]>]>;
+// Types with element width up to 64 bits, used to keep dpp operands legal.
+def AMDGPU_IntOrFloatWidthLeq64 : Type<
+ CPred<"$_self.isIntOrFloat() && $_self.getIntOrFloatBitWidth() <= 64">,
+ "integer or float with element bitwidth <= 64">;
+
+def AMDGPU_IntOrFloatOr1DVectorWidthLeq64 :
+ AnyTypeOf<[
+ AMDGPU_IntOrFloatWidthLeq64,
+ FixedVectorOfRankAndType<[1], [AMDGPU_IntOrFloatWidthLeq64]>
+ ]>;
+
//===----------------------------------------------------------------------===//
// AMDGPU Op definitions
//===----------------------------------------------------------------------===//
@@ -643,8 +654,8 @@ def AMDGPU_RawBufferAtomicUminOp :
def AMDGPU_DPPOp : AMDGPU_Op<"dpp",
[Pure, SameTypeOperands, AllTypesMatch<["result", "old", "src"]>]>,
- Arguments<(ins AnyType:$old,
- AnyType:$src,
+ Arguments<(ins AMDGPU_IntOrFloatOr1DVectorWidthLeq64:$old,
+ AMDGPU_IntOrFloatOr1DVectorWidthLeq64:$src,
AMDGPU_DPPPermAttr:$kind,
OptionalAttr<AnyAttrOf<[I32Attr, ArrayAttr, UnitAttr]>>:$permArgument,
DefaultValuedAttr<I32Attr, "0xf">:$row_mask,
diff --git a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
index 4ed62cacd006f..f9f11c1f9e540 100644
--- a/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
+++ b/mlir/lib/Dialect/AMDGPU/IR/AMDGPUOps.cpp
@@ -674,12 +674,6 @@ LogicalResult SparseMFMAOp::verify() {
// DPPOp
//===----------------------------------------------------------------------===//
LogicalResult DPPOp::verify() {
- Type srcType = getSrc().getType();
- if (srcType.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/invalid.mlir b/mlir/test/Dialect/AMDGPU/invalid.mlir
index 474fca1157118..4429e4758f51c 100644
--- a/mlir/test/Dialect/AMDGPU/invalid.mlir
+++ b/mlir/test/Dialect/AMDGPU/invalid.mlir
@@ -519,6 +519,14 @@ func.func @sparse_mfma_wrong_dest_count(%a: vector<4xf16>, %b: vector<8xf16>, %c
// -----
+func.func @dpp_rejects_scalable(%a: vector<[16]x[16]xi8>, %b: vector<[16]x[16]xi8>) {
+ // expected-error @+1 {{fixed-length vector of integer or float with element bitwidth <= 64 values of ranks 1}}
+ %0 = amdgpu.dpp %a %b row_shl(1 : i32) : vector<[16]x[16]xi8>
+ func.return
+}
+
+// -----
+
func.func @ds_barrier_init_non_workgroup(%barrier: memref<!amdgpu.ds_barrier_state>, %participants: i32) {
// expected-error at +1 {{'amdgpu.ds_barrier_init' op barrier must be in workgroup (LDS) memory}}
amdgpu.ds_barrier_init %barrier[], %participants : memref<!amdgpu.ds_barrier_state>, i32
diff --git a/mlir/test/Dialect/AMDGPU/ops.mlir b/mlir/test/Dialect/AMDGPU/ops.mlir
index c3e7c8b70f4ee..5011891ed39d2 100644
--- a/mlir/test/Dialect/AMDGPU/ops.mlir
+++ b/mlir/test/Dialect/AMDGPU/ops.mlir
@@ -802,6 +802,13 @@ func.func @wmma_scale(%fp8_src: vector<64xf8E4M3FN>, %fp6_alt_src: vector<64xf6E
func.return
}
+// CHECK-LABEL: func.func @dpp_vector_src_does_not_assert
+// CHECK: amdgpu.dpp
+func.func @dpp_vector_src_does_not_assert(%tile: vector<256xi8>, %pop: vector<256xi8>) {
+ %r = amdgpu.dpp %pop %tile row_shl(1 : i32) : vector<256xi8>
+ func.return
+}
+
// CHECK-LABEL: func @ds_barrier_ops
// CHECK-SAME: ([[BARRIER:%.*]]: memref<!amdgpu.ds_barrier_state, #gpu.address_space<workgroup>>, [[COUNT:%.*]]: i64, [[PARTICIPANTS:%.*]]: i32)
func.func @ds_barrier_ops(%barrier: memref<!amdgpu.ds_barrier_state, #gpu.address_space<workgroup>>, %count: i64, %participants: i32) {
More information about the Mlir-commits
mailing list