<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54177>54177</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missing transformation 'popcount (x) == 1 || x == 0' to 'popcount (x) < 2'
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          davidbolvansky
      </td>
    </tr>
</table>

<pre>
    ```
----------------------------------------
define i1 @src(i32 %0) {
%1:
  %2 = ctpop i32 %0
  %3 = icmp eq i32 %2, 1
  %4 = icmp eq i32 %0, 0
  %5 = or i1 %4, %3
  ret i1 %5
}
=>
define i1 @tgt(i32 %0) {
%1:
  %2 = ctpop i32 %0
  %3 = icmp ult i32 %2, 2
  ret i1 %3
}
Transformation seems to be correct!
```


```
src(int): # @src(int)
  lea eax, [rdi - 1]
  test edi, eax
  sete cl
  test edi, edi
  setne al
  sete dl
  and al, cl
  or al, dl
  ret
tgt(int): # @tgt(int)
  lea eax, [rdi - 1]
  test edi, eax
  sete al
  ret
```

src(int): # @src(int)
  lea eax, [rdi - 1]
  test edi, eax
  sete cl
  test edi, edi
  setne al
  sete dl
  and al, cl
  or al, dl
  ret
tgt(int): # @tgt(int)
  lea eax, [rdi - 1]
  test edi, eax
  sete al
  ret
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVMFymzAQ_Rpx0dgjJDBw4JCE5tZbf0Cgta1WRq4kXOfvuwIcG8eHHNJbGQ2sdt9Kb9_O0lr1VpMNmxdrCHtaffKZ0Aq2ugeqU0oy5l1HeKkFp4TnjPCKkuJ5wqEjJeJp2tAYR5BoaBeO9kjfU65hMYZ1dzhS-H0BcMJfaHqDyh6hWETdnpWPKOtGmpgU4_GKC8RBmEP5zLZoZkM0RHx7UGrYhX9R6mDColb-kaK4o_jDyd5vrTvIoG1PPcDB02BpC7SzzkGHRGfJ7jq9eC9Dcyd7zK2wFrxX3DR4cs_MDEgK8jxqmj87pekKW5Q3l3gAHygoHQERN7s9BCRoHqLwc0Wh5NIsstT7VvYqBjHnehK2eXJdYSjeZM5duy9r4f6CsuTHmx9K_1_lL1M5UbVQlahkEnQwUH_X3ut-R8NyOggvcAg7O_QB7fI8Dm6c8YbicBUvuOj54sGxLuIkPU6Kw8mLZHCm3odw9HHk-SuunQ77oV139oAbY06Xz-ro7M9xHF-R3AAejTxLiyLZ1xxErhRXXcrEBtJNxgvZ5V1alYK3GVSJkS0YX6NIhPMe_tDxCLRRrETXnHHOBBNpybJcrMvtpuLpJlVpXnYV_o4yBgepzTryWFu3S1w9UmqHnceg0T74a1CidrseYLwOz5dD2FtXK3nSqrXmhJL-ektGBvVYwV9SwKgr">