<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62312>62312</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[X86] Attempt to narrow CMP nodes if it will avoid using imm32
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RKSimon
</td>
</tr>
</table>
<pre>
As mentioned on https://reviews.llvm.org/D148594, instructions such as:
```s
cmpl $65535, %eax # imm = 0xFFFF
```
where we know that the upper bits are zero, might be more efficiently encoded as:
```s
cmpw $-1, %ax
```
Making use of the implicit i8 sign extension etc.
This might be easier to deal with after DAG - either in isel patterns or X86ISelDAGToDAG, we probably don't need a pass for it (where we wouldn't have the necessary value tracking).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU0-L-zYQ_TTyZUhwxn_iHHxwf8ZLKT8o3T3sVZbG8XRlyUhynPTTFzvLLi2FgrEYmDd67-mNDIGvlqgWxS-iaBO5xNH5-o_fXnlyNumdftRNgIlsZGdJg7MwxjgHkTUCO4GdpxvTGo7G3Kaj81eBXXvKq-KSC_wBbEP0i9rAAcKiRpA7NG1F2ogyfX7hWatpNiAwL4siKza0wILkHQRmwNMEImshvXdd1_0L_yzXkTzBSvBh3QpxlBHiSLDMM3noOQaQnuAv8m6bPfF1jNATTM4T0DCwYrLRPICscpr0_zBdN6aH0ydNef9PSj_lB9srLIHADTsbnmbDiiNwBZv1QPdINrCzQFEdP6fs_7eRwzdNkoHJQ3SgSRpYOY4gh0ge2uYFDkAcR_LAFjiQgVnGSN4GcB7eq_LXVzJt8_Lm2uZlo7wSzN71sjcP0M4KPEewtImGWYYAg_PAEQRWX66ubjH62TnKG-1qLCkKQfoH3KRZCKKXalMs8HJMdJ3pS3aRCdWnskLMi3NZJGN9xn7oMZeKqlOvy6EYdFmlFSrVn7Osx4RrTDFLc8xOKV6wOKZVesJUEWmthpQuIk9pkmy-QpdwCAvVJWYnTIzsyYQ90Yi9VB9ktcia96oUiFvIfb3hDv1yDSJPDYf4Hd8kcjT7Omz9RQtNjDTNcTPeSu_dCj9-_g7WaQrAw2bSysaAvDnWsITtuXmaMkwWb-p_rsqV47j0R-Umgd124edxmL37k1QU2O06gsBul_J3AAAA__8dAiK_">