[Mlir-commits] [mlir] [mlir][spirv] Fix greedy rewriter crash in HandleVectorExtractPattern matches shuffles on block arguments (PR #192213)
Hocky Yudhiono
llvmlistbot at llvm.org
Wed Apr 15 01:55:18 PDT 2026
https://github.com/hockyy created https://github.com/llvm/llvm-project/pull/192213
`HandleVectorExtractPattern` could report `success()` without rewriting the IR when `llvm.shufflevector` extracted a contiguous slice from a **block argument** (no defining op). The greedy rewriter’s expensive checks then aborted with *“pattern returned success but IR did not change”*.
The pattern only performs work when the shuffle’s operand is defined by another op (`FPExt`, `FPTrunc`, `bitcast`, nested `shufflevector`, or `load`). For operands like function arguments, `getDefiningOp()` is null, so nothing is rewritten; the function still fell through to `return success()` without changing the IR and would crash when `MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` is on. `mlir-opt --convert-xevm-to-llvm --split-input-file mlir/test/Conversion/XeVMToLLVM/xevm_mx-to-llvm.mlir` no longer hits the fatal error.
Assisted-by: Cursor (Composer 2)
>From 0ef9745afc136879ec9cd968c8b6c355fff52f4a Mon Sep 17 00:00:00 2001
From: Hocky Yudhiono <hocky.yudhiono at gmail.com>
Date: Wed, 15 Apr 2026 16:50:42 +0800
Subject: [PATCH] [mlir][spirv] Fix greedy rewriter crash in
HandleVectorExtractPattern
---
mlir/lib/Conversion/XeVMToLLVM/XeVMToLLVM.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mlir/lib/Conversion/XeVMToLLVM/XeVMToLLVM.cpp b/mlir/lib/Conversion/XeVMToLLVM/XeVMToLLVM.cpp
index 899422ac42910..e9bb86011c9d9 100644
--- a/mlir/lib/Conversion/XeVMToLLVM/XeVMToLLVM.cpp
+++ b/mlir/lib/Conversion/XeVMToLLVM/XeVMToLLVM.cpp
@@ -1457,6 +1457,9 @@ class HandleVectorExtractPattern
} else {
return failure();
}
+ } else {
+ // No defining op (e.g. function argument): nothing to hoist/merge.
+ return failure();
}
return success();
}
More information about the Mlir-commits
mailing list