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

    <tr>
        <th>Summary</th>
        <td>
            linalg-fuse-elementwise-op pass crashed with assertion failure
        </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>
    ```
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 --linalg-fuse-elementwise-ops temp.mlir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  mlir-opt                 0x00000001023a83b4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  mlir-opt                 0x00000001023a740c llvm::sys::RunSignalHandlers() + 112
2  mlir-opt                 0x00000001023a8a4c SignalHandler(int) + 344
3  libsystem_platform.dylib 0x00000001a45d54c4 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001a45bdee0 pthread_kill + 288
5  libsystem_c.dylib        0x00000001a44f8340 abort + 168
6  libsystem_c.dylib        0x00000001a44f7754 err + 0
7  mlir-opt                 0x0000000103786c14 (anonymous namespace)::FoldConstantBase<(anonymous namespace)::FoldConstantTranspose>::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const (.cold.45) + 0
8  mlir-opt                 0x00000001027a9994 (anonymous namespace)::FoldConstantBase<(anonymous namespace)::FoldConstantTranspose>::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const + 1864
9  mlir-opt                 0x00000001035e1500 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&)>) + 1400
10 mlir-opt                 0x00000001033bbda4 mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 3280
11 mlir-opt                 0x00000001027cc3e4 (anonymous namespace)::LinalgElementwiseOpFusionPass::runOnOperation() + 316
12 mlir-opt                 0x000000010336f534 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 408
13 mlir-opt                 0x000000010336fa7c mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 320
14 mlir-opt                 0x0000000103371148 mlir::PassManager::run(mlir::Operation*) + 744
15 mlir-opt                 0x000000010336adf4 performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) + 696
16 mlir-opt                 0x000000010336a8a8 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>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) + 672
17 mlir-opt                 0x00000001033d35c4 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) + 656
18 mlir-opt                 0x0000000103368d88 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) + 216
19 mlir-opt                 0x0000000103369250 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 1164
20 mlir-opt                 0x000000010224932c main + 108
21 dyld                     0x0000000106601088 start + 516
zsh: abort      mlir-opt --linalg-fuse-elementwise-ops temp.mlir
```


Steps to reproduce: 
mlir-opt --linalg-fuse-elementwise-op temp.mlir

[temp.mlir.txt](https://github.com/llvm/llvm-project/files/9801542/crash-linalg-fuse-elementwise-op.mlir.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWFlv2zgQ_jX2CxFDByVLD35wnKQNECNGEhTYfTEoiZK5pUktSSVVf_0OdfhsEvV4KIo1DEvmMec3w-EkMqtno9Dpvs7VyJnPtabKMClQThin2cifo5EXMU1G_uJJjvxr-PeJ8JEXw3gIX3h4KdHGztftvJ0kqqi2VBgkc8REKrclMSzhFJm6pCPPhV2wbOQtUF6JtOHYULEDwBgt4A8TxWRjRzgTFAVhOGmFXN1dzx-vka6SLTOIoKQqkKKlVAYZiTbGlBrkHnk38C2Y2VTJBASAP5w_94-LUsl_aAoMb5jWFdXwgojIrLC8ykDODUWpInqDEpJ-NoqktGP_aGAAZdW2tFyaIQem4pWShSLbnepWCLTlTF3I0qCLC9CC8OIirzS9oJzaJS8M3mWpkaHbcmLXnrJAL6CArAzS9TaRHAmypdq6hApdKYpqWaENeaaoUapdxL5SBXrYOYVW86ePSCqkqWl0ouKZKSka3zwThcD1d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