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

    <tr>
        <th>Summary</th>
        <td>
            [CodeGen] Boolean expression a != c && (b || (c || a)) and a != c && (b || c || a) lead to different (unoptimal) code
        </td>
    </tr>

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

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

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

<pre>
    The following two functions lead to different results:

`bool fn1(bool a, bool b, bool c) {
    return a != c && (b || (c || a));
}

bool fn2(bool a, bool b, bool c) {
    return a != c && (b || c || a);
}
`
https://godbolt.org/z/v7jP7azxz

This expression is equivalent to `a != c`, which seems it seems to be simplified to nicely in fn2 but not fn1. I think this is a codegen issue, since the expressions are semantically equivalent but generate different IR, since fn1 is generated with an extra block/branch. 

 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0U81uszgUfZrL5qoRmABhwWKaiGl3o1FfwD8XcGvsjG2Stk8_Mk3afD-bLj4JmWPJvuf43Ht4CHq0RB1U91AdMr7Eyfnugazy-uVhIWHJZ8Kpt-5pIhycMe6s7Yjx7HBYrIza2YCGuMLoUOlhIE82oqewmBig_AvyA-TXtc6FcwYHWwDbrZAD2-OKxCeSwFqE5v7jEiKip7h4ixyBFVAeUCKwGliNqQxCs4dmn7C8Yg6sTV95KQLN4VbIRQX7Ayp-lPArf51_gCnG4-oP64H1o1PCmbhxfgTWvwPrT83zPw1_f32_1f006YD0evQUgnYW0-6_RZ-4SaZHh1DnX_ISF9vjedJywkA0B9TxAqJDQRj0fDR60LS2z2pJ5g21TdagWCJaF1OzNviIcdL2Ja0hsXKUTtFISUJYKNEEbSVhnOhGYEDuCQPN3EYtuTFvt3oTw0iWPI90MzuP_36VG2yR6K6nFJ51nJBbpNfoOQrj5AuwXnhu5bTBW68wU12p2rLlGXVFU-waVpdtk03d0LSt2NW8qotBlnLYcbEVpRp4UYo2l3mmO5azbV4Xu6Kq2qrZ5IzvWtaWSlV1ORQlbHOauTYbY05zalq22tC1VbutM8MFmbBmijFL56tHLEXMd-nOnVjGANvc6BDDV5Woo1nDuHeK_iYL1QHvnTO0vviz7d_OAXKrvjO3v0k0sN1i3THqmZt0IvU_W7zpfhpkHadFbKSbgfXpXZff3dG7Z5IRWL-6EYD1H26dOvZ_AAAA___WMlx3">