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

    <tr>
        <th>Summary</th>
        <td>
            [GVN] memcpy miscompile
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    ```
$ cat /tmp/a.ll
define i64 @src(i64 %arg) {
  %call2 = alloca i64
 %call3 = alloca i64
  store i64 %arg, ptr %call2, align 8
  tail call void @llvm.memcpy.p0.p0.i64(ptr %call3, ptr %call2, i64 8, i1 false)
 %load1 = load i64, ptr %call3, align 8
  ret i64 %load1
}

declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
$ opt -p gvn -S /tmp/a.ll
define i64 @src(i64 %arg) {
  %call2 = alloca i64, align 8
  %call3 = alloca i64, align 8
  store i64 %arg, ptr %call2, align 8
  tail call void @llvm.memcpy.p0.p0.i64(ptr %call3, ptr %call2, i64 8, i1 false)
  ret i64 undef ; ???
}
```

alive verifies the miscompile: https://alive2.llvm.org/ce/z/GssD2L
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVM-vmzAM_mvMxWoFDlB64PDeKt5l2mXS7gbcNlsgKAmd3v76KZS-35N2mTQpggTbnz_7M2Hv9WkUqaG4h-KQ8BzO1tUsc8vjD5-0tn-soUzXlR4gvQPKseOAQE0YJqCGt8ZcTb0c9SioyxwhT73rgKrlQAW7E9AeYXd_dcX4sWNjCEEdkI2xHcfI1bxa1cdW9MG6NdGK_Qmn4J5A45mNPo1Y3UICa4PRiBer-0jQmMuwHWTopsftlMYVM1D1Akh9BBzTVssmwyMbL0D7Z9rGcp8ttONuIf0aQ31Azkm4VbPEr63eHdbN2t7OsJO_4j9aNpo9jrbjKcxO8KfTQexoHm903rs44f7msfLWGephuKr3rL-dAm4mPF1G3Hz9Z5Pwvk1_mor3nv_rgDwpPY-9HBHUPYJq1vVG9Df_3fJkoy-CF3H6qMVjOAsO2nd2mLQRUHd4DmHyoO6AmqhIdKftUoiNXWg6AWp-ATUP3h_oc9LXqt-rPSdSZ-VuXxJVhUrOteop32UVC5eFKstdR1WpONsXreI2yznRNaWkUkV5mhV5prZ8zPKemYqqyoiPO8hTGVibp-yJ9n6WuszKXZoYbsX428Xj6ui0aeeTj33XPvjnsKCDWa6oh29foDjgVZEXdSezM_Xrwk86nOd229kBqIlI62szOftdugDULGw8ULMQ-h0AAP__nUx3yg">