[Mlir-commits] [mlir] [MLIR][LLVMIR] Fix llvm.extractvalue folder (PR #201838)

Vadim Curcă llvmlistbot at llvm.org
Fri Jun 5 07:00:10 PDT 2026


================
@@ -185,6 +185,30 @@ llvm.func @fold_extract_sparse() -> f32 {
 
 // -----
 
+// CHECK-LABEL: no_fold_extract_splat_rank_mismatch
+llvm.func @no_fold_extract_splat_rank_mismatch() -> vector<2xi32> {
+  %0 = llvm.mlir.constant(dense<12> : vector<2xi32>) : vector<2xi32>
+  %1 = llvm.mlir.constant(dense<23> : vector<4x2xi32>) : !llvm.array<4 x vector<2xi32>>
+  // CHECK: extractvalue
+  %2 = llvm.extractvalue %1[0] : !llvm.array<4 x vector<2xi32>>
+  %3 = llvm.shl %0, %2 : vector<2xi32>
----------------
VadimCurca wrote:

It is needed to reproduce the crash. If we use the value in a return, the folder gracefully fails when trying to materialize the constant with value `123` and shape `vector<2xi32>`:
https://github.com/llvm/llvm-project/blob/main/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp#L532

When passing the result to `llvm.shl`, its folder actually crashes, because it expects the operands to have the same type.

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


More information about the Mlir-commits mailing list