<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98848>98848</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Failure to optimize shift+compare pattern for sign check when done as a ternary as well as when using a computed goto
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
GabrielRavier
</td>
</tr>
</table>
<pre>
```cpp
#include <stdint.h>
int8_t f(int8_t x, int8_t y)
{
int8_t i1 = (uint8_t)x >> 7;
bool cond1 = i1 != 0;
goto *(cond1 ? &&bb1 : &&bb2);
bb1:
return i1;
bb2:
return i1 + y;
}
int8_t f2(int8_t x, int8_t y)
{
int8_t i1 = (uint8_t)x >> 7;
bool cond1 = i1 != 0;
return (cond1 ? i1 : i1 + y);
}
```
`f2` can be optimized as well as `f1` (i.e. into `return x < 0 ? 1 : y;`). GCC does this, but LLVM does not.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMU81u4zwMfBr6QtSQacexDz7kp-ml3-U77HUhy3SsXcUKJLlt9ukXspM0BfoACwQRRQ7pmYEovdfHkbmB1RZW-0ROYbCueZGt02z-l2-aXdLa7tJAKZafOp9B7EFsgHI9KjN1jJDvfOj0GNIB8udref7XY6h-BuyBqmv4AbTDa3wBqq_o9XYJEPFW1RlCvkegaloyQPUHxg_kz7iG_KGjtdagsmO3tMROymIkvsCONlgE2gBVN_ABgUqgsm3jbXO_UaR2623bDPLN5xzHYXIj6uwBQd8jEGiLlzsO1vvv7KF_wJ8r5S_e6MWUu4wHTz6V3F7GozAoRU9QClRyxJbRnoM-6T_cofT4zsbEM4KyCIrqU06jMBuzVypRzA7FzGQhMhtZCqA6xZfdDjvLHsOgfTStnQK-vv74b8mONqRJ1-Rdndcy4SZbUyZEkRd1MjSrvioV931W54qoJynWpFZ9JeqyLTslEt2QoEKss5UQxaqo0yzLWNZKdcxZX_UZFIJPUpvUmLdTat0x0d5P3NRVVVSJkS0bP28V0cjvOBeBKC6Za2LPUzsdPRTCaB_855Sgg-HmILWZHGOwd-fQD7oPQFtlT2fpGM8yBHYj9tZh3GJUA6vf-D7wiJ0dOTosMUKkuzzaPiMmr8cjSozTpsDdvBvJ5EwzhHD28THTAehw1GGY2lTZE9AhsrweT2dnf7EKQIdZmwc6LNrfGvobAAD___vlO_Y">