<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144282>144282</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM can compile a function differently if there are different paramters even if the demanded bits are the same
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AZero13
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/4nYe6avsv
unsigned func1(unsigned a, unsigned b)
{
int c = a & b;
return (c ^ a)&1;
}
unsigned func1_2(unsigned a, bool b)
{
int c = a & b;
return (c ^ a)&1;
}
Here, the only bit that matters is the bottom one, hence it should make no difference.
However, we get:
func1(unsigned int, unsigned int):
bic w8, w0, w1
and w0, w8, #0x1
ret
func1_2(unsigned int, bool):
and w8, w0, #0x1
tst w1, #0x1
csel w0, wzr, w8, ne
ret
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUU01z2zgM_TXUBROPBH3YOujgbFazh-y1M-2lQ0qwxZYiPSRkN_n1HdKu7TQ5tDqIQz7gvUcQkCHovSXqRP0o6qdMLjw5322_kHdFmSk3vnQT8yGIciuwF9jv3aic4ZXze4H9q8C-sp-pkcdwFPlW5NvFJsoRdosdCoGb64EU-A9cd0pgGzPWjyLfwuXTlmEAUT6BBIENKFHew5548RYEbgYQ9b-RsRXYFOcosX76yMJXfGdCOWf-zsAfKv9HnqIATwTOmhdQmoEnyTBLZvIBdEigcsxuBmdT-ER2INAMYXKLGWGW3wmsg1HvduQjuLrwuxMdycecE8GeOL5LQt5VW1t-U--0b8_xv26r9JDW0yYx5ulfxABpxzNyPku4wDL_Ubx9jjvxt3W-yMdK32SvrHd671g58Dmo-BAeApk7Z6_-ZtDSR-aysSvHtmxlRl2xrvO8zPOmyKZOtq2q6pGqNaFSUo2qVTXhboOFapsSM91hjnXeFDWWuK6KVS3LXYWbpmxwGJqxElVOs9RmZcxxjiOR6RAW6oqqwg1mRioyIc0WoqUTJFQgxlHzXUx6UMs-iCo3OnC40bBmQ93z86f_YZAWBjcftCGQqaNZO3ttDTYvoHexpzyB9HQD4CC9nFPT0ZHsJQpGmqUd4wBqDikjngY5U7Z48_u0a54WtRrcLLCP7i7Lw8G7bzSwwD7dKQjsL5c-dvgzAAD__zgXRwE">