[Mlir-commits] [mlir] [mlir][xegpu] Fix crash on 0D vector in vector-to-xegpu transfer lowering (PR #205812)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Jun 29 19:44:54 PDT 2026
https://github.com/Chennesxu updated https://github.com/llvm/llvm-project/pull/205812
>From d740759c717f198f89612590aeee50e1efdac14e Mon Sep 17 00:00:00 2001
From: Chennes Xu <xuchen359 at gmail.com>
Date: Thu, 25 Jun 2026 21:20:31 +0900
Subject: [PATCH] [mlir][xegpu] Fix crash on 0D vector in vector-to-xegpu
transfer lowering
transferPreconditions accepted rank-0 vectors, which then reached
computeOffsets and indexed an empty SmallVector (broadcasted[0]),
asserting. Bail out via notifyMatchFailure for 0D vectors so the
transfer op is left unconverted instead of crashing.
Fixes #205281
---
.../VectorToXeGPU/VectorToXeGPU.cpp | 2 ++
.../VectorToXeGPU/transfer-read-to-xegpu.mlir | 20 ++++++++++++++++++-
.../transfer-write-to-xegpu.mlir | 17 ++++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp b/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
index 8dcc9771d8db4..dd7330e4ea950 100644
--- a/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
+++ b/mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
@@ -97,6 +97,8 @@ static LogicalResult transferPreconditions(PatternRewriter &rewriter,
VectorType vecTy = xferOp.getVectorType();
unsigned vecRank = vecTy.getRank();
+ if (vecRank == 0)
+ return rewriter.notifyMatchFailure(xferOp, "0D vectors are not supported");
if (xferOp.hasOutOfBoundsDim() && vecRank < 2)
return rewriter.notifyMatchFailure(
xferOp, "Boundary check is available only for block instructions.");
diff --git a/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir b/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir
index f64bcc27940ea..6439e3a41e084 100644
--- a/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir
+++ b/mlir/test/Conversion/VectorToXeGPU/transfer-read-to-xegpu.mlir
@@ -679,4 +679,22 @@ gpu.func @load_0D_memref_unsupported(%source: memref<f16>) -> vector<f16> {
// CHECK-LABEL: @load_0D_memref_unsupported
// CHECK: vector.transfer_read
-}
\ No newline at end of file
+}
+
+// -----
+gpu.module @xevm_module {
+gpu.func @load_0D_vector_unsupported(%source: memref<3xf32>,
+ %offset: index) -> vector<f32> {
+ %c0 = arith.constant 0.0 : f32
+ %0 = vector.transfer_read %source[%offset], %c0
+ : memref<3xf32>, vector<f32>
+ gpu.return %0 : vector<f32>
+}
+
+// LOAD-ND-LABEL: @load_0D_vector_unsupported
+// LOAD-ND: vector.transfer_read
+
+// LOAD-GATHER-LABEL: @load_0D_vector_unsupported
+// LOAD-GATHER: vector.transfer_read
+
+}
diff --git a/mlir/test/Conversion/VectorToXeGPU/transfer-write-to-xegpu.mlir b/mlir/test/Conversion/VectorToXeGPU/transfer-write-to-xegpu.mlir
index a7cd3d7652d85..755b8a3abc4e0 100644
--- a/mlir/test/Conversion/VectorToXeGPU/transfer-write-to-xegpu.mlir
+++ b/mlir/test/Conversion/VectorToXeGPU/transfer-write-to-xegpu.mlir
@@ -412,3 +412,20 @@ gpu.func @store_1D_vector_addrspace3_unsupported(%vec: vector<8xf32>,
// STORE-SCATTER: vector.transfer_write
}
+
+// -----
+gpu.module @xevm_module {
+gpu.func @store_0D_vector_unsupported(%vec: vector<f32>,
+ %source: memref<3xf32>, %offset: index) {
+ vector.transfer_write %vec, %source[%offset]
+ : vector<f32>, memref<3xf32>
+ gpu.return
+}
+
+// STORE-ND-LABEL: @store_0D_vector_unsupported
+// STORE-ND: vector.transfer_write
+
+// STORE-SCATTER-LABEL: @store_0D_vector_unsupported
+// STORE-SCATTER: vector.transfer_write
+
+}
More information about the Mlir-commits
mailing list