<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63113>63113</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ACLE and UBSan disagree about clz with input zero
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tmatheson-arm
</td>
</tr>
</table>
<pre>
[D152023](https://reviews.llvm.org/D152023) made calls to `__builtin_clz` and `__builtin_ctz` with input 0 to be undefined behaviour. However we use them in the `arm-acle.h` to implement `__clz`:
https://github.com/llvm/llvm-project/blob/c91246b71eec9fc1d4454ddcdc574733a699e190/clang/lib/Headers/arm_acle.h#L143
The [ACLE](https://github.com/ARM-software/acle/blob/main/main/acle.md#miscellaneous-data-processing-intrinsics) documentation for `__clz` states:
> When x is zero it returns the argument width, i.e. 32 or 64.
The definitions in the header will need to be updated to handle the zero case.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUUztv4zwQ_DVUs7AgUQ9bhYokjpEiX_M98JXGilxbe6BIg6Ssu_z6A-Xk8sA113hharmcmZ3BEPhsiXrR3Itmn-EcR-f7OGEcKTi7QT9lg9M_UsO-bGQhK9HshdyNMV6CqO6EPAh58HRlWkJuzHXKnT8LeXjrlh1MqAkUGhMgOhBtcTwOM5vI9qjMi2gLQKu_nMf1fOE4AtvLHKFIdweC2Wo6sSUNA414ZTf7HJ7cQlfysBDMgSCONAHbVNNY9NMGlaF8TDOjA54uhiay8fboDUQiU-xF8fr7meCZ4zgPuXKTkIfE8rVsLt59IxWFPAzGDUIeVFfKuh22JZHqTqrUdd3UWiutmm29rSpsu47KrkitBm2SynC6-ESoyQchD-in4yteWT2XdfUR17-JU3N_9_D8-LtNfAJ69_dfm-BOcUFPaa4y9A50QrbvZX1v0kJWEwdFxqAlN4eNxoiJpKIQ2J43bKNnG1iFtFnt1Jx0xMjOwsn5j4JCiBgpfNFVVI_w_0gWvgMHeCHvgCN4irO3Yd0Y-vM6FBbWcRTyATinHCoJzkNb51_VWP3ACUF4W_q4agkLGwOWSL9556Ix3v6NaLVZnXLDoDBQnum-0l3VYUZ92e6arq1l0WRjT1q2uuyolkPddIVsVdlSUahh13XbYSsz7pPZi7ZoylJWsslJbru2aYZ2V57qHbWiLmhCNr8iknEIM_VtVZZVZnAgE9YUSmlpgfWjkDKF0ver04b5HERdGA7xPWhZ5GioT25YQ_Tf_T9oQXPAsycCHNwcQZmXj0lKfLPZm_6PLb6iSg5dUf8MAAD__2cXWg8">