[Mlir-commits] [mlir] [mlir][Arith] Fix crash when folding operations with dynamic-shaped tensors (PR #178428)
Jakub Kuderski
llvmlistbot at llvm.org
Wed Jan 28 06:28:06 PST 2026
================
@@ -3403,3 +3403,26 @@ func.func @unreachable() {
cf.br ^unreachable
}
+// -----
+
+// Verify that cmpi with dynamic-shaped tensors does not crash during folding.
+// The fold cannot create a DenseElementsAttr for dynamic shapes.
+// CHECK-LABEL: @cmpi_dynamic_shape_no_fold
+// CHECK: arith.cmpi eq
+func.func @cmpi_dynamic_shape_no_fold(%arg0: tensor<?xi32>) -> tensor<?xi1> {
+ %0 = arith.cmpi eq, %arg0, %arg0 : tensor<?xi32>
+ return %0 : tensor<?xi1>
+}
+
+// -----
+
+// Verify that select with constant condition and dynamic-shaped tensor operands
+// folds correctly without crashing.
+// CHECK-LABEL: @select_dynamic_shape_const_condition
+// CHECK: return %arg0
+func.func @select_dynamic_shape_const_condition(%arg0: tensor<?xf32>, %arg1: tensor<?xf32>) -> tensor<?xf32> {
+ %true = arith.constant true
+ %0 = arith.select %true, %arg0, %arg1 : tensor<?xf32>
----------------
kuhar wrote:
This doesn't exercise the code you wrote
https://github.com/llvm/llvm-project/pull/178428
More information about the Mlir-commits
mailing list