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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] reduce (C1 / x) == C2
        </td>
    </tr>

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

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

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

<pre>
    The tests for https://reviews.llvm.org/D132888 (which is a fix for [#57338](https://github.com/llvm/llvm-project/issues/57338) reveal another missed optimization:
https://alive2.llvm.org/ce/z/-WrjL2

That could be generalized for any constant numerator, any constant compare value, and also a != ("ne") predicate.

We already have a fold for the related pattern with "udiv" and 0 compare constant, so there may be some opportunity to share/extend the code. 

But that fold is probably also too specific and has enhancement potential. For example, it doesn't matter whether this is sdiv or udiv, they both reduce to the same thing:
https://alive2.llvm.org/ce/z/A8uou8
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyllMFu2zAMhp_GvhANHDlxnIMPbYICA3Ys0DMtM5EKWTIkOmn69KOcdWuPwwBHtkOR_P6fSvow3LoXQ8CUOMEpRDDMUyrqx0I9yxXpYumaVs5dxlWIZ_nquK5V27ZQqPZqrDZgEyCc7PuSXmyfClVvd3XdFtuj7Ple72zZzP1Kh1FectHft4cphjfSLK82pZmSPNyLqD0IBKED9IENRRhlBw0QJraj_UC2wef61bGoHr93Q2cvpL7Ca5LlQz4Pr_Htp7on3dcXgww6zG6AnuBMnqLkf0inrAv9TYI-MXoGP48S5BALdfgeEWETRoILupnu0QHQpSAWFWpd1MfsW6GUl6jK4qZIg9XItPoK80qSFQmHGxi8UDY4uDuJeCCOOMkYYEJmih6uYqsUVvNgL3JbulZ_YD7pMo-QZBMJRrxlnSmMJFZOIfLsLd-AAyQjWeIRvTNJodxQh4FW8JXwaWaJiGULmJwBmWCPvbvd5XKQOhNpe7J6wTGYgLxBr2kkcWoKUpwtuhU8iyp6x3Fyi2WWYQiUfKF2LJhZIVwNLbNnI53kSiIUJO0u-JAZRY6cD7FmmDVlGZk7ociTJH_-9yPy2M5hbkvq1k2jVLVXzbocunrY13ss2bKjTk77D_H2EMbeykS3x8_2MuTDWtZneM9Dlrnn0R9UOUfX_c9PYrtRpemIdLvRGyS9I9w3u52uUOenqsZq01DpsCeXMp9AlbZTVVZQ1Wu12W3Wq1OzrXDXaFWfmpNsLTYVjWjdHx_K2C0M_XxOEnRW_h7-BjEle_ZEn_VxZhNiFwPLqYz2bLhckLuF9xcZiW33">