<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57597>57597</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
align the load to word size before entering the loop in __murmur2_or_cityhash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hiraditya
</td>
</tr>
</table>
<pre>
The for loop loads from `__data` one word at a time. is `__key` guaranteed to be aligned to `_Size`? If not then aligning it before entering the loop may give performance improvement with aligned loads.
```cpp
// murmur2
template <class _Size>
_Size
__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
{
const _Size __m = 0x5bd1e995;
const _Size __r = 24;
_Size __h = __len;
const unsigned char* __data = static_cast<const unsigned char*>(__key);
// start from beginning for alignment.
for (; __len >= 4; __data += 4, __len -= 4)
{
_Size __k = __loadword<_Size>(__data);
__k *= __m;
__k ^= __k >> __r;
__k *= __m;
__h *= __m;
__h ^= __k;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVM1unDAQfhpzGQWBWcJy4JDNJlLP7X1lYAA3gJFtNt0-fcc2u0nbRFWRZTyeb_5nXKv2Un0bEDqlYVRqoU20BjqtJmD3yenUCivoAGpGeFW6BWFBgJUTxiBNwLzgxUH6VWgxW8QWrIIaQYyynwPlcF_lT6Q_y57hSwezsmAHnANKzj1IS0LkCAKSFu2uCBDcmsQFenlGWFATZBJzgyCnRaszTgSHV2mHm0EfRMySI0setp3s-tUsy3bDn2nBtGpaPNxZnJZRWASWPTajMAaC09lT4AcqHE-b5EnpUyPtZRBmILEA4Y-QcSeWPdBS5LSwSjO-Z7ykvVGzsXBWsmX8AUICScTLEjni7HDBzeIQDkBfkLvCqELZEZIfed2mWJY5yz6Fag_lO4LAG-bKHTw32P1bxzqbkNVmEDr465rCyxgrrGxOjTDWpexDvEsD329Blr8Z2GpAWrQNPVdjL2ffDa4jfT1deeM3GXfvEkmReI_Bp_kIu3ATXOOHcOWS6kF3G12-M14c3H6j32fk5ZoRaiTX9bfCbrH4qfgjGC_vJF3ITnj6mJ0_BfZL8PzJlef_FQ3_ZN_s_J7y4niL-jYUEVbp_T3P03SX5lFbZW2ZlSKy0o5Y-SJskyj8MPt3wLhMfTqvcoYPJyRa9VgN1i7GjYYvf0-Tu9ZxoyYixvF8_d3RcH_HxhIpjVnR0CEv8rKIhqpoeVkWu30jUtEVHc-TLu1E03T1HtOuS6JR1DiaiuUHxvmMr-BV0Jnlx0hWPOE8KZMiSXZZlscUbFrkiMjbbk_vF9slOAk5xs6PWOk-0pV3qV57Q8xRGmvemPRQuI5Hb470i9UOSleD1KKluEXkjVfe-V-3PJ_F">