<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120392>120392</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
affine dialect → emitc dialect an error occurred
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pyl3000
</td>
</tr>
</table>
<pre>
When I run `mlir-opt --lower-affine --convert-scf-to-emitc --convert-arith-to-emitc --convert-memref-to-emitc --convert-func-to-emitc matmul- affine.mlir -o matmul-emitc.mlir` with the following error:
![Image](https://github.com/user-attachments/assets/41928739-9bff-4cfd-92cb-8384784dfc2f)
matmul- affine.mlir as follow:
```
module {
func.func @main() {
%cst = arith.constant 0.000000e+00 : f64
%cst_0 = arith.constant 6.000000e+00 : f64
%cst_1 = arith.constant 5.000000e+00 : f64
%cst_2 = arith.constant 4.000000e+00 : f64
%cst_3 = arith.constant 3.000000e+00 : f64
%cst_4 = arith.constant 2.000000e+00 : f64
%cst_5 = arith.constant 1.000000e+00 : f64
%alloc = memref.alloc() : memref<2x2xf64>
%alloc_6 = memref.alloc() : memref<2x3xf64>
affine.store %cst_5, %alloc_6[0, 0] : memref<2x3xf64>
affine.store %cst_4, %alloc_6[0, 1] : memref<2x3xf64>
affine.store %cst_3, %alloc_6[0, 2] : memref<2x3xf64>
affine.store %cst_2, %alloc_6[1, 0] : memref<2x3xf64>
affine.store %cst_1, %alloc_6[1, 1] : memref<2x3xf64>
affine.store %cst_0, %alloc_6[1, 2] : memref<2x3xf64>
affine.for %arg0 = 0 to 2 {
affine.for %arg1 = 0 to 2 {
affine.store %cst, %alloc[%arg1, %arg0] : memref<2x2xf64>
affine.for %arg2 = 0 to 3 {
%0 = affine.load %alloc_6[%arg0, %arg2] : memref<2x3xf64>
%1 = affine.load %alloc_6[%arg1, %arg2] : memref<2x3xf64>
%2 = affine.load %alloc[%arg1, %arg0] : memref<2x2xf64>
%3 = arith.mulf %1, %0 : f64
%4 = arith.addf %2, %3 : f64
affine.store %4, %alloc[%arg1, %arg0] : memref<2x2xf64>
}
}
}
memref.dealloc %alloc_6 : memref<2x3xf64>
memref.dealloc %alloc : memref<2x2xf64>
return
}
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyslt9uozoQxp9mcmMRmbEhcMFF0jTSPsG5XDnGBI4MrmzT7r79Ef-SNMfdRdmtEIXBv8_fTMxg4Vxz6ZQqIDlActyI3tfGFm8_NaOUbs6m_Fn8U6uOfCO27wiktNWNjcybJ1GkzYeykaiqplMkiqTp3pX1kZNV5E2k2sbLu7Cwja9DD1rVWhVEqr6Tt3grfNvriEwTbgcjJDJLeBwzBiGl5KPxNfG1IpXR2nw03YUoa40Ftgc6HhhDcvjWiouC5AiY1d6_ueExngBPl8bX_XkrTQt46t2QpvdC1q3qvAM8CefUeMHjHLMdy6P8XFURl1UZ5SjPUcYyvst4WUmsAPNp0lAGws0e4fUEhxfIF4MpnQ-6b03Za0VgdwC6J2Qoy3Y4EeC0FU0HmAHm1-eEACbSeQLsSMayb6XpnBedJ3RLxz8FeKCUANuTKuWfsO80BKYrwDgEJitADIF8BchCIFsB8hCIK8AkBMa_AYXWRo7gtNi3Y2D52dh-DgN7wR_4Y0DZ6wP9PV3Js8_8vNacN1ZdcwB8uROG5ECHCIXk-IQaD6vFz6mxsBo-p4b_U4v_INM4rPZkpjSstj7TytiRt5fpjaXEG4J3bSAwMv5qZNDjvcPhCzFJLFF7CdXxYf0GXeDNBXtwMa74uQNNmDai_FynZfKrjxU1u2rHa7Tj57TxS-0_qN6ofN_o2l5XYyaz1GPDuUL3TU6U5QgtbwQLQo9rgP-lFQC74_Xudn27mttaqeZOed_0flX5L7jfOLLK97YbbyYL83n55G7KgpU5y8VGFfGO8SRmu5Ru6iJPqp1KeM5pTjPKd1UslGCp5HGVp5UsN02BFHmMcUZzRE63aZpJzmm6OytkOc-AU9WKRm-1fm-3xl42jXO9KmKkLMeNFmel3bIbs8UwKjr3Fwec6sZ5d-N847Uq5t1X2QitpCfwipClkCOZ9kxLnIhu2gARI2VvrSo3vdXFLzY9wzzzv-jNmn-V9ICn0eyw75n9vhf4XwAAAP__LU7i7w">