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

    <tr>
        <th>Summary</th>
        <td>
            Simplifications of `max/min (a & c0, a & c1)` under `(c0 & c1) == c1/c0`
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    The following two functions can be simplified, and this is motivated from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109878.

```c
#include<iostream>

unsigned foo(unsigned a, unsigned c0, unsigned c1)
{
   return ((c0 & c1) == c1) ? std::max(a & c0, a & c1) : (a & c0);
}

unsigned bar(unsigned a, unsigned c0, unsigned c1)
{
   return ((c0 & c1) == c0) ? std::min(a & c0, a & c1) : (a & c0);
}
```

Alive2:
https://alive2.llvm.org/ce/z/kQrReA
https://alive2.llvm.org/ce/z/UQay5M
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0k8tu2zoQhp9mtCFiUENLlhZaOPHh7izSy7qgSEpiQ5EBL3GTpy8kO27cG1AUBQRJPzg_Zz7MjIjRjE7rDqpbqA6FyGnyoXu4ESH4Yyx6r567D5Mmg7fWH40bSTp6MmQnk_EuEikc6TWJZn60ZjBaAd4R4RRJk4nERDL7ZJ5E0ooMwc9kSukxAtsDckA-SrkZXd74MALyPo8vxloByOPkj5_6PG7kaIBxo4AdSto2u2YD9AB0f37X9PTIs0ZmnLRZaWB3xscUtJiB_ffWk92KrMjgPWBzkWKp_KIkvZYlYHu-ZXd7-iGEBJ1ycASwAWwkJYD1KZQAOwA7XAQnMakFm-1n8QWwEafYNYu48u3J1XEL7PY18eGnHL0I_56D_shh3N9yvHbvLdbemieNS4pVXs-LWA831j7N55mRGpC_APKH-_BO_6np4714rv4vVMdUy1pR6K6s2y2yuqyrYuqqnVDDrqxZ1feK4bbWsmmwwbISbVNrUZgOKTLa0pZWtMVqU9GKCt2yndSMlbqGLdWzMPaSvTAxZt3VVcNYYUWvbXzdvdAtQTd9HiNsqTUxxW-2ZJLV3fvzmklx2j4_EKjpOlF8No78uiFQU5Kd0mEx_GZYuVwaUuRgu-9W1aQp9xvpZ0C-lHX-3DwG_1nLBMhXtAjIV7qvAQAA__-Qdz0G">