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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] fold signbit test of a pow2-or-zero
        </td>
    </tr>

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

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

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

<pre>
    This probably isn't worth the compile-time cost of using ValueTracking, but we could add a direct pattern match for this and similar icmp patterns:
```ll
define i1 @src(i8 %x) {
  %negx = sub i8 0, %x
  %pow2_or_zero = and i8 %negx, %x 
  %cmp = icmp slt i8 %pow2_or_zero, 0
  ret i1 %cmp
}

define i1 @tgt(i8 %x) {
 %cmp = icmp eq i8 %x, -128
  ret i1 %cmp
}
```
https://alive2.llvm.org/ce/z/_J5q3S
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk1FvmzAQxz-NeTklMkcI8MBD2whpe12118gGB24zmNpH0_bTTyZJ222aNAkJbH7_u_-dzyoE6idjapHfi_yQqIUH52vvWLHx1A-caNe91o8DBZi900rbV6AwCSwYzs7zADwYaN04kzUbpjEuAoM7wRJo6uG7sot59Kr9SVMv8AH0wnCO1GI7UF0HCjrypmWYFbPxE4yK2wFOzgPHvGrqINBIVnmgdpxvXBDZnZAHIe_EXl4eay8bnTnRZIBSEDsZfCuwpBIE5i8CKxDF_QWDuDWZ_gVEdoCwaKASZDS5oh_M7M54dP74Zrxb2ejpEjHKbwr4JIlGI7k6Dpav-OdIUSZvEm949bsqr2UVh-vH30Vxz_8q6s_k5gneuQfYpFj-V85bTy_LgXleG46NwEZZeja4tfZ53DrfC2xaI7B5E9gcv-ZP2bekq7OuyiqVmDrdF0VaVGWKyVCXeYZllueV1lrJqtOZxn3eqarcq12OmFCNEjOJmKVVus9xm6UnXbWpkbrKq10rxU6aUZF9z55QCIup97LKi8QqbWxY5xlxMmdYfwrEON6-jpqNXvogdtJS4PARhYntehG-TIEf3KhpMiI_wMnZOH_9pImBzWW2FcSD3Di_iQeZLN7Wv3eoJx4WvW3dKLCJOa6vzezdD9OywGZ1FgQ2q_NfAQAA__9j8g_4">