<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64269>64269</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] `mlir::vector::TransferWriteOp::getSource() ` 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 b4c54b20
Reproduced with:
`mlir-opt "--convert-vector-to-scf=full-unroll target-rank=0" temp.mlir`
temp.mlir:
``` milr
func.func private @func2(%arg0: vector<22xf16>, %arg1: vector<22xf16>, %arg2: vector<22x22x22xf16>) {
%c1_i64 = arith.constant 1774520363 : i64
%c1_i32 = arith.constant 1268727148 : i32
%c1 = arith.constant 1 : index
%c31 = arith.constant 31 : index
%6 = tensor.empty(%c1, %c31, %c1) : tensor<?x?x?xf16>
%alloc_17 = memref.alloc(%c1) : memref<?x22xi32>
%42 = affine.if affine_set<(d0) : ((d0 + 64) ceildiv 64 >= 0, (d0 - (d0 + 64) - d0 ceildiv 64) floordiv 128 == 0)>(%c31) -> i64 {
%136 = tensor.empty() : tensor<i1>
%141 = vector.broadcast %c1_i32 : i32 to vector<3xi32>
vector.transfer_write %141, %alloc_17[%c1, %c1] {permutation_map = affine_map<(d0, d1) -> (d0)>} : vector<3xi32>, memref<?x22xi32>
affine.yield %c1_i64 : i64
} else {
affine.yield %c1_i64 : i64
}
%43 = math.log %6 : tensor<?x?x?xf16>
return
}
```
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 "--convert-vector-to-scf=full-unroll target-rank=0" temp.mlir
#0 0x00000001024b0548 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8548)
#1 0x00000001024ae7e4 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f67e4)
#2 0x00000001024b0bf4 SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f8bf4)
#3 0x00000001a46cd4c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
#4 0x00000001a46b5ee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
#5 0x00000001a45f0340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
#6 0x00000001a45ef754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
#7 0x00000001068a64dc mlir::vector::TransferWriteOp::getSource() (.cold.1) (/workspace/build/bin/mlir-opt+0x1046ee4dc)
#8 0x000000010418854c mlir::vector::TransferWriteOp::getSource() (/workspace/build/bin/mlir-opt+0x101fd054c)
#9 0x00000001045e0498 (anonymous namespace)::lowering_n_d_unrolled::UnrollTransferWriteConversion::matchAndRewrite(mlir::vector::TransferWriteOp, mlir::PatternRewriter&) const (/workspace/build/bin/mlir-opt+0x102428498)
#10 0x0000000106153b74 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+0x103f9bb74)
#11 0x0000000106150e70 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+0x103f98e70)
#12 0x0000000104b992b4 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() (/workspace/build/bin/mlir-opt+0x1029e12b4)
#13 0x0000000104b96ae4 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/workspace/build/bin/mlir-opt+0x1029deae4)
#14 0x00000001045e79c4 (anonymous namespace)::ConvertVectorToSCFPass::runOnOperation() (/workspace/build/bin/mlir-opt+0x10242f9c4)
#15 0x0000000104b39e34 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x102981e34)
#16 0x0000000104b3a524 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102982524)
#17 0x0000000104b3c3bc mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x1029843bc)
#18 0x0000000104b34808 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10297c808)
#19 0x0000000104b33d30 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+0x10297bd30)
#20 0x0000000104bb2be0 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+0x1029fabe0)
#21 0x0000000104b2e6e4 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+0x1029766e4)
#22 0x0000000104b2eb54 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x102976b54)
#23 0x00000001021bb58c main (/workspace/build/bin/mlir-opt+0x10000358c)
#24 0x000000010d879088
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWVtv47rx_zTKCxGDIqnbQx68dvz_L7DBBsn2nEeDkkY2uxSpklQ27qcvqEtsOntJfA7aou0im-gynMtvfpwZSdxasVMAN1HyIUrWV7x3e21uVlpK3WnjeouvSl0fbu4-fXxAZS-kQ9yhSretcAiVrEpYSXCE1xFePkBndN1XUKNvwu0jukRovBOluJXCXOvOoYiQ6-tKqycw7voJKqfNtdPXtmoium56Ka97ZbSUyHGzA3dtuPoa0TWOCEEO2m7hNUXpZHP8fbxOly8Wxx_UCmnQqTBCTa-qhf-FOiOeuAMUMezPSUTyiCTc7LD3fvQuoitCnps4jehtRFZoFIh_JUDOBcafWaxAUfZhdgj5NVW8FSlDEV0jboTbLyqtrOPKoTjLWEIwTSnySkXKpoXTKkq-u4qkeUaymOXjKi8V2vvuqlFY1fB8Jk6_K09PFgTy6SDtQFltFtB27jCCW8UTRhV9OYoHPOhyEo_oKqKb5_n_BNmpci6lrrZxNthooTXQLIZrRxujwvHepJCQZ0HJuS42odc0QsFCNNPR1oLz60he41nboD2vMYrIB5Qyf7kCIWvxhIbM3XpFeIzKi12jc_FrVOOTNf5SI7U2_jQmPlPrSUcx0CSfgSrQdURv0cCQU-IMIcT0B2ifoSriIPhxLRvzOlJ1URrN64pbF5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