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

    <tr>
        <th>Summary</th>
        <td>
            Failure to determine condition is always false using known bits
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            missed-optimization
      </td>
    </tr>

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

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

<pre>
    ASCII letters can be converted to lowercase by or-ing with `0x20`. Therefore the 3rd `if` in `src` is impossible and should be deleted:

[godbolt](https://godbolt.org/z/WeKbxEao3)
[alive](https://alive2.llvm.org/ce/z/NSVJ7q)
```c
#include <stdint.h>

typedef uint32_t u8;
typedef uint32_t u32;

u32 src(u8 b) {
    if (b >= '0' && b <= '9') {
        return b - '0';
 }

    b |= 0x20;

    if (b >= 'a' && b <= 'f') {
 return b - 'a' + 10;
    }

    if (b >= 'A' && b <= 'F') {
 return b - 'A' + 10;
    }

    return -1;
}

u32 tgt(u8 b) {
    if (b >= '0' && b <= '9') {
        return b - '0';
 }

    b |= 0x20;

    if (b >= 'a' && b <= 'f') {
 return b - 'a' + 10;
    }

    return -1;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVM1u4zYQfprRZWCDGlqSddAhiVfAdoFetmiPBSmOLHZp0SWpZLNPX9BR_poELXquYVAiZ74fktCnYrTHmbmD6hqqQ6GWNPnQfTmx-mbnQntz3119vfn8GR2nxCHioGbUjIOfbzkkNpg8On_HYVCRUd-jDxs7H_HOpgmhFuI7CajFFn-ZOPDoA2OaGGUwuWpHqAXaOb_HMFwmEe3p7GO02jGq2WCc_OJMVjXsOLEBeQXiAOJxrK6P3mjvElQHoP2U0jnmHuqB-rW09eEI1P8A6n_jL_r7J-UlUPvEoJy95ffwlwJtnbs9rRwDr0Q_f_31p-bPZ5ZaPPyHdU7SzoNbDCPIm5iMndN2Avnppfl0f2bDIy52TpJ-T7jsQV5_VJP0VHwYF0mYD472yx41UIvQrA2IiHZEoL3GLCoPCNQIoAaBaqAa8_rNut4CNW_g-Rc4LWFGjZtH-JMFhObw0kxu1wjNhfNy8a_Nvu9IfeBofOPotZUVd43ls05WeMfUW9GrD0T7fxC9-veiK3BTPp_C66Z8d-mY_r-7_3yMjx9cYTppWtmqgruyKVuqhGiqYuqEGvWOjRyGclRDPZajkEQsS96ZVlV1YTsStBM17cqGmmq31U2pdCkUyZGr3VjCTvBJWfcUAIWNceGurauyLZzS7OIlPYlONkY2G39O9mR_qGT9DEQ5VkOX0Ru9HCPshLMxxWe-ZJPjrlfWLTkcPRpOHE52vqSssZknp6Jyd-o-4qhcZFxiDtlvs7-bUdsUiyW47m_BZ9O06O3gT0B9Vlsfm3Pwf_CQgPrLViJQ_7Cb247-CgAA__9mMJsi">