<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117620>117620</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Better codegen for overflow checking and extracting that value, and then setting to -1 if it overflows yields better codegen than the much more succinct saturated add instrinsic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AreaZR
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/zPM1f5vjs
Despite these all having the same behavior, not only is the one with the bigger IR resulting in better codegen, but it is also not being optimized to the more succinct saturated add intrinsic
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEkk9v3CwQhz8NvoyyMtiOdw8-bN7I0nuoVOXYG3_GNimGFTN2mnz6it2squbSA0LM_HgknkET-TkiDqJ7Et1zpTdeUh7OGfWPl8ok9z4szBcSzVmoUahxTs6kwIeUZ6HGj7K-f5NTt7-SqM-iPj8jXTwj8IKEoEOARe8-zqUApFcEg6WSslD_QUwMKYZ38HQNpIjw5nm5HoyfZ8zw_wtkpC1wofgIBpkxg00OZ4yFYjYGz4WhA6Ur1GBJpwv71X-gA05X5JoyAm3W-mgZSPOWNaMD7Rz4yNlH8rZyQ-NOzUlXOMi-Ud1jqx5VtQw46cngsWnbSRo9yd5Nx-NR1_aka92f-soPqlatlKqTp07W6tBa2bVSueZoe6ydEW2Nq_bhEMK-FomVJ9pwkLJ_VHUVtMFA92HkoaQezDaTaOvgienPPfYccHj6ywVMKUPaMU8hvYFd0P4sFnR0gL84a8u3QWiGXYcNi7vS5AUjEPKtneBBgp-K0TuL4N1jcPTFfUHFm9fNLv-QS3e7Ww5fP5XnZTMHm1ahxvLCz-3hktMrWhZqvGoiocZPU_ugfgcAAP__89PvaQ">