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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -O1/O2 on x86_64-linux_gnu since Clang-16
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          shao-hua-li
      </td>
    </tr>
</table>

<pre>
    This seems to be a quite recent regression.
`opt-bisect-limit` suggests that the bug might be in `IndVarSimplifyPass`.

Compiler explorer: https://godbolt.org/z/zobd581cf

```console
% cat a.c
int a, b, d;
unsigned c;
int main() {
  int e = 4;
  for (; e; e--) {
 b = 4;
    for (; ((b + 61) << (b + 4)) - 16636 >= 0; b--) {
 c++;
      d = a > 0 && c < 7 / a || 0;
    }
  }
  return 0;
}
%
% clang-tk -O1 a.c && ./a.out
Floating point exception
% clang-tk -O2 a.c && ./a.out
Floating point exception
% clang-tk -fsanitize=address,undefined a.c && ./a.out
%
```

I have reported another with a similar test case, not sure if they have the same root cause: https://github.com/llvm/llvm-project/issues/62515

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVMGO4zYM_RrmQjiQ6diJDz5MkhrY0xZo0R4XssTYamUpleTdmf36Qs5kJttuT11AUexHvkdaJCVjNKNj7qA-Qn3eyCVNPnRxkr6YFllYsxm8ful-nUzEyDxHTB4HRol_LSYxBlbsEgYeA8dovNuCOIN4gkb4ayoGE1mlwprZJGgExmUcOaaIaZIJ08Q4LCPOZpxSVjUOoREfnP5Nhl_MfLXm8vKzjBEacddd95Ofr8ZyQH6-Wh84QPWEU0rXCNUTUA_Uj14P3qatDyNQ_zX__KDrQ6kuj0rQiNtS3kVv-RWlGpVMKLfqBhiXUAKdcMibhup4wxe3np9G9QZl11kaB3QAahH2rzhitjBCdcbdmzfixQfMvtURed2K4lve8C_KN6Q1zmFAoCM25UqtTlCd8A3dAbUZL7BsmqpBqH7KiiKzh39GU0DHvB6jIeo1B5mpKBCoAWpQ5Ui4R6A-m_Yn2J9W1Xcm7M_3l4fHwGkJ7sH1zQZUP1TASjcW6U8sPpa5FPe4W6Bebv2Sbq699TIZN-LVryf8rPiajHffFaIfJHSJ0plkvjJUZ6l1bn6g0-I0X0zuh_-O8v6J99Z77McPOMnPeayuPqSs43yaOOAXkyaUGM1srAyYOCZUMnJuR-cTxiUwmkseqZebRB6uKGfG4H32XSJ_Z0pMmpZhq_wM1Fv7-f5XXIP_g1UC6k2MC0egvqG6fE19o7tKt1UrN9yVzaGu2rIksZm6Stf7QZXioOtyr4cDKXGRPOhBibYpL3JjOhJUiZpaEiUJsW2rQcnDvqK6vOg9S9gJnqWx25xGnt7NmkDXUNvSxsqBbVxvKyLHX3A1AlG-vEK3pj4sY4SdsCam-K6STLLc_R68G1F5zShT7iug_iOhd_h8aD41u8Iatzx_Gt2C0TjFeForXjabJdju_5xd29LfAQAA__9tcJCq">