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

    <tr>
        <th>Summary</th>
        <td>
            [X86] Inefficient legalization of sadd.sat with constant operand
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:X86
      </td>
    </tr>

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

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

<pre>
    The current legalization of sadd.sat on X86 is inefficient for the common case where we know the sign of one of the operands (e.g. because it is constant). In that case we only need to check overflow in one directions.

https://llvm.godbolt.org/z/fxzWTqorW
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0kU-PozAMxT9NuFiDgkMpHDjMqkKa-0gz15AYyDaNu0mY7vTTr2C7_w57wRKxn_3eT6fk5kDUi8MXcTgVes0Lxz64szPFyPazf10IzBojhQyeZu3dXWfHAXiCpK0tk87AAd7bBlwCF2ianHFb-8QR8jbOlwsHMDoR3BaKBDeCc-Db_rodsIlxoK1sv_hKUQebQGBL5VzCSEavicDlbYfhkLIOWWBXwkuAvOj8UCfg4D8hEFnIDGYhcwb-oDh5voEL-xbrIpnNQyqFPAn5_PO75HxNQj0LHAQO3n9cypntyD6XHGeBw13gMH2_v71-4_hW2F7ZTnW6oL5q2mPVdLLFYunxIBUppSeLVukaUTdHc6w6qjorlTSF61Gikk3VVVLWNZZHbbHW7dhQa1RdNaKWdNHOl_sNHOfCpbRS3yjVNoXXI_m0A0MctTlTsEI9v7eNQNwYxn6bexrXOYlaepdy-qOUXfY77a3_cIKXv3j9F-_N5eV36r_oFGv0_b-ZzS4v61gavjwCfJSna-SvZLLAYXeSBA67mR8BAAD__7XT00g">