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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -O2/3 on x86_64-linux_gnu (a latent regression since Clang-15)
        </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 looks like a long-standing issue since Clang-15. Clang at -O2/3 produces the wrong code. `opt-bisect-limit` suggests that the issue might be in `LoopVectorizePass`.

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

```console
% cat a.c
int printf(const char *, ...);
long a, c;
long *b = &a;
char d;
char *const e = &d;
int f, g, h;
int main() {
  long i[] = {1, 4, 4, 1, 4, 4};
  for (; g >= -6; g--) {
    f = 0;
    for (; f <= 5; f++)
      c = i[f] ^= *e > *b;
    *e = 1;
  }
  for (; h < 1; h++)
    printf("%d\n", (int)c);
}
%
% clang-tk -O0 a.c && ./a.out
4
% clang-tk -O2 a.c && ./a.out
1
% clang-tk -O3 a.c && ./a.out
1
%
% clang-tk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git a5bba98a58b7406f81629d3942e03b1eff1e2b33)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
%
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VV2r4zYT_jWTm8FGHtlOfJGLnGT98kLLFrq0l4ssKbZ6FClY8u7p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