<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/105869>105869</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] Numeric Mismatch with AArch64 when using CodeGenOptLevel::Aggressive
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nirvedhmeshram
</td>
</tr>
</table>
<pre>
An mlir test https://github.com/nirvedhmeshram/iree/blob/main/tests/e2e/regression/layernorm.mlir#L75 showed numeric mismatch only on AArch64 after some graph level optimizations were enabled. The difference at the start of the divergence which happens after a divison + multiply + subtract (with various level of brodcasting) computation on tensors is small we see `-1.49012E-07` instead of an expected 0. But of course later on in the model it gets amplified to become significant. Interestingly the answers are correct with CodeGenOptLevel::None. Even using CodeGenOptLevel::Less causes the issue.
Here is the optimized llvm IR dump (withCodeGenOptLevel::Less) which gives the mismatch
https://sharkpublic.blob.core.windows.net/sharkpublic/nirvedh/arm_numeric_issue/optimized_arm_ir.ll.txt
Here is the base IR that does not give the mismatch
https://sharkpublic.blob.core.windows.net/sharkpublic/nirvedh/arm_numeric_issue/base_arm_ir.ll.txt
Also here are the respective assembly code generated
https://sharkpublic.blob.core.windows.net/sharkpublic/nirvedh/arm_numeric_issue/optimized_assembly.s.txt
https://sharkpublic.blob.core.windows.net/sharkpublic/nirvedh/arm_numeric_issue/base_assembly.s.txt
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lc9u4zYQxp-GvgwiSLRlywcdnGbdLpBugaL3gCLHIlv-ETgje92nL6jYDYKme8zFhkRq5vcNvxkqIjdGxF60j6J9WqmZbcp9dPmMxgYkm1VYDclc-0OE4F0GRmKwzBOJ9UHIo5DH0bGdh0qnIOTx_bdCHl1GFPI4-DQIeQzKRSGPJQoJeURZ1jKOGYlcKkteXTHHlENV8gm5ft61QDZd0ECcA2anITgKirWFFP0VUoTDIWu73YA6MWagFBDGrCYLHs_oIU3sgvtbsUuR4IIZAaMaPJoK_rAIxp1OmDFqBMXAFoFYZYZ0Wh6MO2Mel-WLddqCVdOEkW7pVNngKEUQ8hHC7NlN_ro80DxwVppByO7i2MJZZZdmunOdYMjJaEXs4ijkHnQK08wLaNHFGCllAkdAQXkPFwRCBLGtH5pqs68b-eWh3oltDS4SozIlpoqA3yfUjAbqCh7nRYlOcyYErwpziuDiIi4kgx4cw4hMoMLk3cmhAU4woC6VLB5xJ6dV5Aq-RsaMC6-_LgFUpAtmApURdMoZNcOi9adk8GeMv038XNQWv6wP31LECr6cMcJMLo4f73pGItBqJqQlhyOasRL1k6gPv5Tjc6_vbweLBrw_B_j6O5g5TPdq_2_oUunXkxzd-Zbi7qnXJO8dTlblv6Z58E5XxciVThmri4smXaiKyO_3vLWBkEeVw8vNty-LDCGP_2K_lFWXK-8r_s7_1TcowqKKrWIwCQli4gX605kLyke4r78HTwlsIS82KGwZqViwoCoiDIO_gk4GYcSIWTGaT670DaKiN_bPqNgHaVemX5v9eq9W2Dc7udmsd81-s7J913YSu06121qrHTZ66NQg633T4r7DPa5cL2u5qTu5brpm326q9c7oU7c1bdc0TWvWYlNjUM5XpR-qlMfVQtM3ddtt9yuvBvS0jHspI17gxirL9M99-ehhmEcSm9o7YnoLw479ck_cRq1on-DbbRz_eh_HS9vfZ_HF_rjHD-Pr1D_jas6-_8GdUiBufw9TTn-iLkexoJdL5Kbt3Mt_AgAA___inVvM">