<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/128152>128152</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Power of two assumption optimized away
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
https://llvm.godbolt.org/z/z3E6641E1
```llvm
; RUN: opt -S -passes=instsimplify < %s
define i1 @foo(i32 %x) {
%ctpop = call i32 @llvm.ctpop.i32(i32 %x)
%cond = icmp eq i32 %ctpop, 1
%ext = zext i1 %cond to i8
call void @llvm.assume(i1 %cond)
%res = icmp eq i32 %x, 0
ret i1 %res
}
```
Results in:
```
define i1 @foo(i32 %x) {
%res = icmp eq i32 %x, 0
ret i1 %res
}
```
Note that the dead `%ext` is relevant.
Without looking into it, I assume that the problem is that we're using https://github.com/llvm/llvm-project/blob/aad74dc971f789b2974fde4181f87ee20db2998d/llvm/lib/Analysis/InstructionSimplify.cpp#L6307-L6310 with an ephemeral value, and the extra use in `%ext` is what makes use currently think it is non-ephemeral.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2PpDYQ_TXmUmrkD7qBAwdmZ1taabWKdhXlbHDROGNsYpvu6fn1kT29PTNKDom0EghMvVev_KqwDEGfLGJH9g9k_1jILc7Od1Y_6bEYnLp2c4xrIKIn_Ej40ZjzUp6cGpyJpfMnwo8v6RafD4eKfWaE9uRAX6-ETWvxAN9__0ZED26NsPsBu1WGgIGIR21DDHpZjZ6uQMQnIHwfCO0VTtoiaAakopNzhDda8BR9JrwFUj8Q2kNaj3F1KxDxCKM0BjKqytJlDpVa8I_sO9NZlYl6XFbAv-CGyTTCPwH7icTnmIEv6SXVdCNHB7rJoKx9dlrdxWUI24JJ-Y5_p-0x_Jv0c5KlGeTxp5TH5AipH997S2j_HcNmYgBtU3c-xv6bf7-okG8uIsRZRogzgkKpIAWyb-RAQQfwaPAsbSwTlfZ_6Di7LYJx7knbE2ibrIxJ9Au8OveWcPVuMLikNPnbBQmvPcIWEvXjeJ50nLehHN1ym9XbY7d69yeOkfDjYNxA-FFKVVdqbGs21U078LauJoUVa9jU1IicqoG3baPe5dGJ11tprkEHwo9fbIh-G6N29sdthstxXQkXXw-C1ruvB8EoXHScQVrAdcYFvTRwlmbDtFeZZmhGwOfoJWwBQdt_WHdJe17kE4aMGDfv0UZzhThr-wQ6JpB1dncXKAvVCdWKVhbYsbqiTFAuWDF39cgnSluGrD5QRikXA0oqKyaloOOkCt1xyveUc0ZbQQUrke5VI5txxIEKiTWpKC5SmzIPufOnQoewYcd4w_a8MHJAE_JhwrnFC-Qo4TydLb7LrRi2U0h_iQ4xvKWJOhrsfnMX9OAmiBf3OghrsjcdHHrRL6hAXuS12Lzp_nfjcympb7dazx3_OwAA__99_IOy">