<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64069>64069</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] `llvm::operator+(llvm::Twine const&, llvm::Twine const&)` crashed with assertion failure "cast<Ty>() argument of incompatible type!"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Colloportus0
      </td>
    </tr>
</table>

<pre>
    MLIR built at commit  585cbe3f
Reproduced with:  
`mlir-opt "-sparse-compiler=enable-runtime-library=false vl=2 reassociate-fp-reductions=true" temp.mlir`

temp.mlir:
``` milr 
module {
  func.func @func1(%arg0: memref<26xi1>, %arg1: vector<12x26xi1>) -> memref<?x?x?xi1> {
    %c17 = arith.constant 17 : index
    %c24 = arith.constant 24 : index
    %c30 = arith.constant 30 : index
    %alloc_18 = memref.alloc() : memref<12x26xi1>
    %alloc_23 = memref.alloc() : memref<12x26x21xi1>
    linalg.broadcast ins(%alloc_18 : memref<12x26xi1>) outs(%alloc_23 : memref<12x26x21xi1>) dimensions = [2] 
    %alloc_26 = memref.alloc(%c24, %c17, %c30) : memref<?x?x?xi1>
 return %alloc_26 : memref<?x?x?xi1>
  }
}
```
 
trace:
```console
Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 566.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: mlir-opt "-sparse-compiler=enable-runtime-library=false vl=2 reassociate-fp-reductions=true" temp.mlir
 #0 0x0000000102674f18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8f18)
 #1 0x00000001026731b4 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f71b4)
 #2 0x00000001026755c4 SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f95c4)
 #3 0x00000001be7894c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
 #4 0x00000001be771ee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
 #5 0x00000001be6ac340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
 #6 0x00000001be6ab754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
 #7 0x000000010691675c llvm::operator+(llvm::Twine const&, llvm::Twine const&) (.cold.1) (/workspace/build/bin/mlir-opt+0x10459a75c)
 #8 0x0000000103ce78a0 (anonymous namespace)::GenericOpSparsifier::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const (/workspace/build/bin/mlir-opt+0x10196b8a0)
 #9 0x00000001062f70f0 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_2::operator()() const (/workspace/build/bin/mlir-opt+0x103f7b0f0)
#10 0x00000001062f43ec mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/workspace/build/bin/mlir-opt+0x103f783ec)
#11 0x0000000104d23420 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() (/workspace/build/bin/mlir-opt+0x1029a7420)
#12 0x0000000104d20c50 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/workspace/build/bin/mlir-opt+0x1029a4c50)
#13 0x0000000103cc6bc4 (anonymous namespace)::SparsificationPass::runOnOperation() (/workspace/build/bin/mlir-opt+0x10194abc4)
#14 0x0000000104cc42a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x1029482a8)
#15 0x0000000104cc4998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#16 0x0000000103cf2a4c mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation() (/workspace/build/bin/mlir-opt+0x101976a4c)
#17 0x0000000104cc42a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x1029482a8)
#18 0x0000000104cc4998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#19 0x0000000104cc682c mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x10294a82c)
#20 0x0000000104cbed14 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102942d14)
#21 0x0000000104cbe368 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x102942368)
#22 0x0000000104d3c34c mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/workspace/build/bin/mlir-opt+0x1029c034c)
#23 0x0000000104cb8d1c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10293cd1c)
#24 0x0000000104cb918c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x10293d18c)
#25 0x000000010237f510 main (/workspace/build/bin/mlir-opt+0x100003510)
#26 0x000000010dd9d088 

``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWV1v2zrS_jXMDRFDIvV5kQs3jt-3QIMGSbF7GVDUyOaWIrUk1cTn1y8oybEpJ23j7Tm7OHuKJnbE4cwz30ORWSs2CuAKpR9Qurpgvdtqc3WtpdSdNq630UWl693V7aeP97jqhXSYOcx12wqHcVqkvALaoGiFouU9dEbXPYcaPwm3RXSJ8biCsqiVwlzqzmFEyKXtmLFwyXXbCQkG0RUoVkm4NL1yooVLKSrDzA7RVcOkBfxNIroi2ACzVnPBHFw23aWBuudOaGURXTnTAyIEO2i7hZeGsmiSPvw-PKfLF1Tjf9wKaSaora57CRjlH8a_MW56xRf-F0ZJ5D9jRApEUmY2kdexhdZAg-g1yZ5FjOgNItd4XI_9-jfgThtEr2PyfCAp8SWiN4fNiK6f9z8DyTEE7PnxOMeIrjAzwm0XXCvrmHJ4eLrEQtXwHNKT5DX64emr9DR6jX54-ho9k1Lzx7gYNo16LIZng3lKHNjmWPdTJoS-gwmJ53ykUExuFpXRrObMOi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