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

    <tr>
        <th>Summary</th>
        <td>
            Lowering ne/eq with constant on compressed ISA
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:RISC-V,
            performance
      </td>
    </tr>

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

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

<pre>
    Noticed this while digging through some SPEC code.
```
93 06 e0 05   li      a3, 94
63 18 d6 00   bne     a2, a3, <small-offset>
```
For immediate values which fit in an uncompressed immediate field, but don't fit within the compressed immediate field, we can instead use an uncompressed subtract followed by a compressed branch on zero.

Resulting code would look something like:
```
sub a3, a2, 94
beqz  a3, <small-offset>
```
This is clearly profitable for minsize, but since it increases critical path length, it may not be generally profitable.  (Though, it probably is for out of order cores.)

If a2 is otherwise unused, we can actually reduce register pressure with this transform.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU11v2zAM_DX2C9FAkZI0fvBDl7ZAgWEY2mLvkkXbWmUp1UeD9NePchosw4oBMwQnEine8Y5WXh_bbz6ZDjWk0UQ4jMYiaDMMxg10FHweRoh-Qnj6freDzmtcVOy2YjfVhn2sedsIYBtABmwNANbA_EhR8R00q1PORsByC3oDjFFMOTzl8JJzyqzELk7S2ivf9xFTJe4-Bbv3Acw0oTYyIbxJm3Hm3o3QmwTGgXSQXeenfcAYqbvf2b1BqwuWygm0dxW_TvOtgyEJHDWN8O-LB0qg-sbFhFJDjvgXXMwqBdlRYW-tP9CJOoK8rKuCdETXO3jH4M-azu9HjNmmYkCRGw4-Ww3W-5fZiEJyIIFfsBI3n6pD4B9ynqQ9y6_w9R3-T-jnMhS0Oosy2CPsgyeppKIh6cmDiTQw73hWMxrXIcwGdAFlJFO6YGi8pIW9TCNYdEMaSzolTfIIzidQCAM6DMTmEmABUPHt81gm8OMGBRWFjoVRgfeE6XvwQWMgrUjZRcWbSykfetKgpHuyNRwMWZUdGXbpI9mUZ-yAOhP_gIMhZwPMVuWA82Scvg8y1UWCnv4wrNat0I1oZJ1Msth-JcdDccmRNPf4eirQeRoY6VLx_GIQHp5u6hxsO6a0j8VSfk9roBtZLSiPNta-nX-uSIOf2CXaGiKHkf6sN6JZ1mOres5RikZdM7ZRS6FlJ3qB_ZpLwfst1lYqtLGt1l8qzpXsXtBpQnx8eNpd_aCjeTA432MoLdJ8Yjlc39am5Yxzds3Wy-1yI1YLpqjmSnea9-utxKZaMZyksYvCceHDUId2pqvyECloSdH4OyhjNINDnKlQfZnT6ENLksgJYz131s5t_QLf_X6V">