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

    <tr>
        <th>Summary</th>
        <td>
            Missed optimization: Fold (a ^ (b || c)) && c to (a ^ 1) && c
        </td>
    </tr>

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

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

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

<pre>
    godbolt example: https://godbolt.org/z/Wrx8KEa17
Code example:

```cpp
#include <algorithm>
unsigned long long int m, n;
void fn1(short a, unsigned long long int b, short c) {
    n = (a ^ (m || c)) && c;
}

void fn2(short a, unsigned long long int b, short c) {
    b = m;
    n = (a ^ (b || c)) && c;
}

void fn3(short a, unsigned long long int b, short c) {
    n = (a ^ (b || c)) && c;
}
```
In fact, these three functions are equivalent and can all be converted to n = (a ^ 1) && c.
However, clang lacks arithmetic optimization and dead code optimization for these three functions. The assembly code should theoretically be optimized to the result of gcc for fn1 in the godbolt example.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lMtu6zYQhp9mtBnEkEhdF1okdoQWRXcFCnRHkWOLLUW6JOXEefqCkpsmQQqcCw5g0BLnH_4fqeGIEPTJEvVQPUB1yMQSJ-f7Pyb9tFzFy0RFNjp17U9Ojc5EpGcxnw0Bv8cpxnMAfg9sADbcBDvnT8CGF2DD7_65_eVRFA3kB8jv907Rm_Rt8jbW-faT5_NthnFtpVkUIfC9MCfndZxm4I9bfLErtkLj7GkbtI04A9ujBf6wqS5OKzzaAlgbJucjihT_n9wxxTaZBNYhNLdVEBEtAj8gsFYgVI_pYUZo9tDsV_GqZzWwGuWrOzSHt5u8wbDvhxlXmPnV6HPA8RsB-Y84ra-B-bcYttefLR6FjMkuThQI4-SJ8LhYGbWzAYUnpL8XfRGGbERhFUphURiDI6F09kI-ksLoPnIVb0F2m91P7oku5JOdNCLtWMi_kkkqP4paojtHPesXkdxXN0VCoUzV_S50dP5z4h3-NhGKEGgezXXLDJNbjEp655OLMOaa8G8rbvhxIvQUFhPRHfEk5epxtAVquwY_XNJdpnquOt6JjPqiKdqy6Lq6zaa-rJUsGtaVx4qLsiurivFS8LYcVdEpITLds5yVeV1UOatY2e5GLkvO27qgcmw6PkKZ0yy02RlzmdOlz3QIC_VdVbMuM2IkE9aewpilJ1yDwFhqMb5POXfjcgpQ5kaHGP5bJepoqP9Vh0Dq3XmmjjM4o76srNJxff6ds8Wb_kPr0nFaxp10M7Ahkdz-7s7e_Ump9oaVPwAbtv1devZPAAAA__9GJo0B">