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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] `mlir::arith::getIdentityValueAttr` 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 --lower-affine temp.mlir`

temp.mlir:
``` milr 
module { 
  func.func @func2() {
    %cst = arith.constant 5.158400e+04 : f16 
    %c1 = arith.constant 1 : index
    %c2 = arith.constant 2 : index  
    %71 = affine.if affine_set<(d0, d1, d2) : (d2 ceildiv 16 >= 0)>(%c1, %c2, %c2) -> f16 {
      %128 = affine.parallel (%arg2, %arg3) = (0, 0) to (8, 7) reduce ("maxf") -> (memref<8x7xf32>) {
        %alloc_33 = memref.alloc() : memref<8x7xf32>
 affine.yield %alloc_33 : memref<8x7xf32>
      } 
 vector.warp_execute_on_lane_0(%c1)[32] {
        memref.assume_alignment %128, 8 : memref<8x7xf32>
      }
      affine.yield %cst : f16
 } else {
      affine.yield %cst : f16
    } 
    return
 }
}

```
 
trace:
```console
Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 572.
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 --lower-affine temp.mlir
 #0 0x0000000102a18f18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspacebin/mlir-opt+0x1002f8f18)
 #1 0x0000000102a171b4 llvm::sys::RunSignalHandlers() (/workspacebin/mlir-opt+0x1002f71b4)
 #2 0x0000000102a195c4 SignalHandler(int) (/workspacebin/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 0x0000000106864790 mlir::arith::getIdentityValueAttr(mlir::arith::AtomicRMWKind, mlir::Type, mlir::OpBuilder&, mlir::Location) (.cold.4) (/workspacebin/mlir-opt+0x104144790)
 #8 0x0000000102ba66ac mlir::arith::getIdentityValueAttr(mlir::arith::AtomicRMWKind, mlir::Type, mlir::OpBuilder&, mlir::Location) (/workspacebin/mlir-opt+0x1004866ac)
 #9 0x0000000102ba6910 mlir::arith::getIdentityValue(mlir::arith::AtomicRMWKind, mlir::Type, mlir::OpBuilder&, mlir::Location) (/workspacebin/mlir-opt+0x100486910)
#10 0x0000000104831534 (anonymous namespace)::AffineParallelLowering::matchAndRewrite(mlir::affine::AffineParallelOp, mlir::PatternRewriter&) const (/workspacebin/mlir-opt+0x102111534)
#11 0x000000010669b0f0 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 (/workspacebin/mlir-opt+0x103f7b0f0)
#12 0x00000001066983ec 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&)>) (/workspacebin/mlir-opt+0x103f783ec)
#13 0x00000001050b8c5c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) (/workspacebin/mlir-opt+0x102998c5c)
#14 0x00000001050b115c (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) (/workspacebin/mlir-opt+0x10299115c)
#15 0x00000001050b32a4 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/workspacebin/mlir-opt+0x1029932a4)
#16 0x0000000104836cf4 (anonymous namespace)::LowerAffinePass::runOnOperation() (/workspacebin/mlir-opt+0x102116cf4)
#17 0x00000001050682a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspacebin/mlir-opt+0x1029482a8)
#18 0x0000000105068998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspacebin/mlir-opt+0x102948998)
#19 0x000000010506a82c mlir::PassManager::run(mlir::Operation*) (/workspacebin/mlir-opt+0x10294a82c)
#20 0x0000000105062d14 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspacebin/mlir-opt+0x102942d14)
#21 0x0000000105062368 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&) (/workspacebin/mlir-opt+0x102942368)
#22 0x00000001050e034c 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) (/workspacebin/mlir-opt+0x1029c034c)
#23 0x000000010505cd1c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspacebin/mlir-opt+0x10293cd1c)
#24 0x000000010505d18c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspacebin/mlir-opt+0x10293d18c)
#25 0x0000000102723510 main (/workspacebin/mlir-opt+0x100003510)
#26 0x000000010e0a9088 

``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWV1v47oR_TXKCxGDoj4sPeTBcRJ00QQJkuD20aCpkcwuRaoktYnvry9IybEpZxPn9qJdXHSxiPVBzpwzZzgkRWoMbyTARZRdRtnVGe3tRumLpRJCdUrb3uCztaq2F3e33x7RuufCImoRU23LLUJZkbE1JHWEryK8eIROq6pnUKEXbjdRskBoeBPluBVcn6vOovNzoV5An9O65hKQhbabuZdRjsfG_u_-ebJ4MzL8Ry0XerTcqqoXgKL55fgAobqXbOb-oCjF7pdEpIhI6Rrt2iAUkYwZi6LkClHN7WbGlDSWSouyWZwVKcYQkUucIkejjnMUdo3f6xn7xlxW8Bq2Ju-1JvvWKLQ-H637CM14PV6tDNgoWUakqHBElqiK_V_iuSUL5F4QxICLiv9ADnJy7ezgiJTu0kUhY76TB3VwUaLzKLkeeB5GycOJSXGIp6OaCgECDQapbnaWqG6SAcyVe-lBOufIKndfuPu5u9fg0mQwQFr6WkdkDyIiRQuthjpKlsXr_LVOiEdfTqF5cFQIxVZJ4p0O_Wb-2U70ZIHeMzfYGSltOYhqYu2jboPz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