<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61223>61223</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed fold for `(n - 1) / 2` when `n` is odd
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jeremy-rifkin
</td>
</tr>
</table>
<pre>
```cpp
int foo(unsigned n) {
if(n % 2 == 0) __builtin_unreachable();
return (n - 1) / 2;
}
int bar(unsigned n) {
return n >> 1;
}
```
```asm
foo(unsigned int):
lea eax, [rdi-1]
shr eax
ret
bar(unsigned int):
mov eax, edi
shr eax
ret
```
https://godbolt.org/z/3G7enYdnM
https://alive2.llvm.org/ce/z/m3qbdN
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEUs1y2yAQfprVhbEHLZKNDjokddRTeu8pA2ZlkSJwAaVNn74j21ESN201GiGW72-ZVSnZgydqob6FeleoKQ8hto8UaXxeRdt_s77QwTy3sOHnd388At8Bv7E-sz4EQDn5k4phHrBhsL09AxhjzPaA0jPAmiEDsQOxY3xGPTzoybps_cPkI6n9oLQjQAnYgHgRiJSnOLOlZytWntSxY7ggYLu7_CyRtIr_jnQR9QzEHYg7Vn6g9tLsW_GlqNJ4rlx1b30-pb959ZofR-q0kvoJ-IlBfRuNXZVQ797j0hAX3LuDSPlcuGrt2m8MT2-NyNj_GSzKHzY85HxMszx2gN0hGB1cXod4AOx-AXbi85b8V-Pv_05Szj4Rrp17Gi_EPV3Yo_iuzZczqTCtMI1oVEFtudnKEjdlI4qhbbQxkkiWVaV6XfdbValelqglclGjLGyLHAUXfFNK3tRijaj3qup1L0uqhNFQcRqVdUuGwqY0UbspEUXhlCaXXqY_tjNopadDgoo7m3J6pWWbHbX3NiUyrA9u_kQ2X9kf07nh7MdAfj7088YmFowppujaqzu1eZj0eh9GwG52uiyrYwyPtM-A3SltAuxOgX8HAAD__7_MBUc">