[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:18:58 PST 2026


================
@@ -2531,6 +2534,10 @@ OpFoldResult arith::SelectOp::fold(FoldAdaptor adaptor) {
             dyn_cast_if_present<DenseElementsAttr>(adaptor.getTrueValue())) {
       if (auto rhs =
               dyn_cast_if_present<DenseElementsAttr>(adaptor.getFalseValue())) {
+        // DenseElementsAttr::get requires a static shape.
+        if (!lhs.getType().hasStaticShape())
+          return nullptr;
----------------
kuhar wrote:

nit: Should we check this in the outer `if` instead? As-is, it seems like a potential typo, but I realize we can check either.

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


More information about the Mlir-commits mailing list