<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60403>60403</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[x86_64] [Optimization] Maybe missed optimization: can't read/write a 32bit address directly
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
youngbe
</td>
</tr>
</table>
<pre>
For this code:
```c
#include <stdint.h>
void kkk(uint32_t f)
{
*(uint64_t *)(uintptr_t)f = 1;
}
void kkk2(uint32_t f)
{
(*(void (**)(void))(uintptr_t)f)();
}
```
Compile with gcc-12 -O3
```
kkk:
movq $1, (%edi)
ret
kkk2:
jmp *(%edi)
```
Compile with clang-15 -O3
```
kkk: # @kkk
movl %edi, %eax
movq $1, (%rax)
retq
kkk2: # @kkk2
movl %edi, %eax
jmpq *(%rax)
```
Maybe this is a missed optimization?
clang version: 15.0.2-1, installed by apt on Ubuntu 22.10
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlEtv-jgUxT_NzeaKyLlOAiyy4DHZjbqaNXJiA26dmNoOLfPpR3lQ6MBfbYSMX8fn3J9kC-_1oVWqgGwN2TYSXThaV1xs1x4qFVVWXorSOgxH7bG2UgFfAdsCW0HOxl89jYnrtjadVAh844PUbYiPwP-alof2bLXEt7c3oEWn28BpF3APtJz2zNdjBxERaDXtytNdGIfLaeYU3C4ALfcIfIsJ8PX1gO0zN_qV3WJ0HETX0eTZzw29hwDjVN8-ZrgCuo-0sc1JG4UfOhzxUNezhHD2wp8qek5X2jh9jT2_j3HTBGgzBs2U1F9VoVPhS08PB7w2J7zh_Z_258i1Ee1hlmQ_hMZffEAcIWW94CthY88Gr6E2Q098flt-Ur0Tn7fqEXsA798I3FnRA04zHvgny4nZ-w3Yvd1TYH-LS6XGG6M9Cmy090qiPQXd6H9F0LYFXt4rBqp4Vs4PaytMspjFNBuK1K0PwhglsbqgOAW0Lf5TdW3okChOWCQLLpd8KSJVJPk8S9KEiEfHoq4FkxWleSLFntg8XWaCiGSeEl8spIx0QYw4S3jCMsaIYrHnYr_Yq5rySsl0DylTjdAmNubcxNYdIu19p4qcpYxHRlTK-OvL4Yp-06zqDh5SZrQP_iYLOpjhjflc5Ls8hWyLkK1f7olkWxzBPcW1wlq0QPOATgkJVH44HRQK5FTpgEJKp7xHqZ2qg7lEnTPFMYST7y8AlUDlQYdjV8W1bYDKPtj0Nzs5-6rqAFQOxXmgcqjvvwAAAP__XbRiWQ">