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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] memcmp can be optimized when the result is tested for [in]equality with 0 
        </td>
    </tr>

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

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

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

<pre>
    * test case: https://godbolt.org/z/1Wxdhch7a
```
bool f(char *a)
{
    char t[] = "0123456789012345678901234567890";
    return __builtin_memcmp(a, &t[0], sizeof(t)) == 0;
}
```

* this issue is first reported for gcc, while the llvm also has a significant room for improvement,expected assemble should be similar to the sequence used in GLIBC memcmp:
```
        ldp     data1, data3, [src1, 16]
        ldp     data2, data4, [src2, 16]
        cmp     data1, data2
        ccmp    data3, data4, 0, eq
        b.ne    L(return2)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1U0tv2zAM_jXyRVggS37p4EMe6zCg9x0LWaZjDbKVSnLT9tePctJma7vAlsnw8VEfyc71Ly3hWxohRKpVACK2dIzxFFAg_A6fo-s7Z-PG-SNqr_jmv577UY-1IuxA2JZU7PqsauecpQPhjR6Vp5hcES6vnvXuIlD8reZIyh0pD5QIfDlnORdFWdWN_FJCDyL-SuEhLn6mDw_dYmw088MEk55OiI2Ye0xYpfwMAZIazCu4VFhMBXGZQBMue89J6sOXV7qeiafRBGpCWABPOhiPtHk4OR-hp4Pz9Kh1wjqPxgJ6A7X2aaLKBkdHFajCKo6zGYxWM0Y6N61RZjp59wQTzJF8vyO7PWn28HwCndKqEGDqMF0Y3WJ72qFkJmMTfW7FCPC4wKyBLgH9zUx_3P_c7emVDbH9z6Wk7U949iqqPBWdBLESV-6C1-t_eZXY-xzA3wKKWwD_HJDwPyDwm_FmFf-kY-mAx3fHbjMDfu6xd5eW89tIvV0qgzavqqKoC1mIrG9FL4VUWTTRQov1bbdej1WRhu3CC477nLh0p4hsviJx5xHmlU8PYbExdTjtxbWzmMPMGI5cK2viCz2bOFJGs8Xb9sPKoGXpNtpNqKQBuH6-YZd_Y1NRXWcooFA2rMqzse3qgkle9UyIoShVLkTdy6GCAsomV5pnVnVgQ7oKrsEM58sYppUoD5lpOcP1kVzmDZOMb7q8Y6qWTEpdlUMDpGAwKWM3qY60y5lv15K65RjQaE2I4WbEmcM5hZW5lF8tcXS-fRr6YchW4HYt_A-FQD6e">