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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][arith] `ceildivsi` wrong lowering
        </td>
    </tr>

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

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

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

<pre>
    The following code computes the value (`ceildivsi -128 7), and should produce `-18`. However, the compiled code will output `18` on trunk.

A similar bug was previously reported in https://github.com/llvm/llvm-project/issues/89382, but the fix addressed only the constant folder. It appears the lowering is incorrect as well.

https://godbolt.org/z/4KzG3chYG
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyckj2TnDwQhH-NSKaOgkGwEBDcvVvc63LqxKGQBpCtRZQ-wHu_3iX2_Bk6gUTd0_NMC-_1vBL1rH5h9TUTMSzW9ZteZ7_oe8xGq-79p4VgssbYQ68zSKsIpL1tMZCHsBDswkQChi1rCknaKL17DU8ltnBh2DH8D8SqwC82GgWbsypKAtYUT2WS5PC_PWgnlx4mv2SuDanHqEMbAzaGLYakOSVgVwgurl9zVlxZ8fz4PoPXN22EgzHOcAgPm6Nd2-jNHRxt1gVSoFdYQtg8q54ZDgyHWYcljrm0N4aDMfuP39Pm7BeSgeGgvY_kGQ5tV7WYco4xnFkn_Q2EUo68JwV2Nff3FVYfxBoSN0Uuhw8BxLaRcA9kxh7kEk3tQa_SOkcygPBwkDF_LPVXVqtGa0Ju3cxweGM48I9vr5VcPr9mqq9UV3Uio768IO-Q17zKlr4pp6mrxo5XHUne8XZsGrpMOI21lFxdMt1jgbxosSs6jljlzdRMpeI0ST617WVkvKCb0CZPWNLs7ATSl0VTl11mxEjGnx1CvBntGGJqk-tPjGOcPeOF0T74Xw5BB3P27hTUV1a_CKfDwuor_N6jdO3D2XX-ySyLzvT_fsL30HuP3wMAAP__80D4WQ">