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

    <tr>
        <th>Summary</th>
        <td>
            Non-deterministic results from MemorySSAUpdater due to iteration order
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mikaelholmen
      </td>
    </tr>
</table>

<pre>
    llvm commit: 6e66cfeeaec6

Build opt with and without LLVM_ENABLE_REVERSE_ITERATION and then do:
```
build-all/bin/opt "-passes=loop-mssa(licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>)" bbi-104167.ll -o bbi-104167.norev.ll -S
build-all-reverse/bin/opt "-passes=loop-mssa(licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>)" bbi-104167.ll -o bbi-104167.rev.ll -S
```
Then if we diff the two output files:
```
diff bbi-104167.norev.ll bbi-104167.rev.ll
```
we get
```
11d10
<   %0 = load ptr, ptr @ao, align 1
15c14
<   %1 = load volatile i32, ptr null, align 1
---
>   %0 = load volatile i32, ptr null, align 1
42c41
<   %2 = load volatile i16, ptr null, align 1
---
>   %1 = load volatile i16, ptr null, align 1
77c76,77
<   store double 0.000000e+00, ptr %0, align 1
---
>   %2 = load ptr, ptr @ao, align 1
> store double 0.000000e+00, ptr %2, align 1
```

[bbi-104167.ll.gz](https://github.com/user-attachments/files/19447973/bbi-104167.ll.gz)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUVE1v4zgM_TXKhXAg0V_xwYckTYABOl2g7c61kC061q5sGZKcYPbXL-R2Z7KZouh1DAGyJb5HPpKm9F6fRqKa5TuW363kHHrr6kH_Lcn01gw0rhqrvtfGnAdo7TDowNItFFQUbUckqS0Y3zK-3c3aKLBTgIsOPchRLS92DnB__-3ry-Fhu7s_vDwevh0enw4vX54Pj9vnL388LJahpxGUZWlkYgV_W3zbRNZEGsPw2OiR4TF6YIjJJL0nz9I7Y-2UDN5Lhhuj24Gl-9FGiL34idrZyKDtyNIDw_1i62yQgVi670kqcomaJ6PbN6vdaJPJ0SQdJZ11iQn2DfpK_S5vxRChaXQieCaKcm0MJPb6YLSOzsvx07WoxNGZnKffW9y1tOvaPcei6g4uBEp3XSwyhIsFO4dpDtBpEyXeVnwxfS91v3i8AV4IThRuDoVQIu4s3QMAw5wDS-_AWKlgCo7hPm7AMi5t_JBGn0YQEZm3IrtGip_Is435MQQ6xf8oxjk26TVDkiQL_vCL58_hM2wzcR0Bvscgik9H8K6Cj_Bl2Zbxuix_hOGDdQTKzo0h4Gu-PMRwx_mPZGLOP4wDP1uDiPicQ7wBXrVAXPnufw28Pv3D8juGmz6EaelBPDI8nnTo52bd2oHhcfbkEhmCbPuBxuAZHl87Fo-iyrKyKtP4297SYrVSdaqqtJIrqkWZYcWLPMtXfV0K1ZQd8qrpBG02G6wakXNquwrbJm-qla6RY85TzAVmiPk6L8qKNxnvOqJNioplnAapzTpO47V1p5X2fqZapFhhsTKyIeOXUY440gWWW4YYJ7tbRnjSzCfPMm60D_4nTdDBUP1gx0RRIDfoUfugW3DkZxM8dM4O8JUG674_PW3_nJQM5EDNBMGCDuSWcQHWKXKr2Zn6g8RGp29bMjn7F7WB4XEJdUnuq5Zzjf8GAAD__-nn_rU">