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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Missed strlen despite unreachable() in noinline increment function.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    https://godbolt.org/z/z9q399GEe
C code:
```
#include <stddef.h>

__attribute__((noinline))
size_t inc(size_t n){
    return n + 1;
}

size_t f0(char *str){
    size_t i = 0;
    for(; str[i] != '\0';++i){
    }
    return i;
}

size_t f1(char *str){
    size_t i = 0;
    for(; str[i] != '\0';){
 if(inc(i) != (size_t)(i + 1))
            __builtin_unreachable();
 i = inc(i);
    }
    return i;
}
```
Clang should be able to optimize f1() to strlen or at least to f0().
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0U02PmzAQ_TXDxdrIjPk8cIBk01NvvSODJ8GVY6e2Wan76ysnRNltVfVUNMhiPB_vvWFkCPpsiTooBygPmVzj4nw3eJLqm7tkk1M_uyXGawDRAx4Bj2enJmfizvkz4PE9ve0P0bZfXgl4v2ezU5SCeQ8V34z3gELb2ayKGIh9iErRabeAeE13vB9HGaPX0xppHAEbwMY6bY22BNgm433Q7zRGpu0M2GwfNl3VA_CeMcY8xdVbZhngwHIQyQ_14d5iyzhxwGZepGeAfYj-U4FHCwbiwPi9QPKfnE-gxMBSRjloKA8MME9hgDWUe54OMQAm05-K3hF8wKf_giz_v8ge1fQJsLmrmIA-ozdRb4I3ehPxoT778IzjtGoTtR1X60nOi5wM3abWbsjuOJ9NnoD_ocaHX2ZvpD2zsLjVKDYRS01YdMxdo77od7oLlhhEl9gbssx5JiMzJENM3tuwAdtdpjqhWtHKjLq8LrAt6qLOs6WraiVUrirZiplzgcVERV1iPilRNzNhpjvkWHKBFee8EPkurxBlVU9ERLUqKyg4XaQ2O2PeLmkrMh3CSl0uBMc8M3IiEx775bsU9TKt5wAFNzrE8MyLOprbJt6Yp0F-1SGQepBTFK46EvtDdKYte6xLEt3ThWxkp9XOUTu7y1Zvft9iHZd12s3uAnhMCLbj5erdd5oj4PFGIwAeNyZvHf4KAAD__7ROMNQ">