<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58223>58223</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -Os on x86_64-linux_gnu
</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>
```console
% clang-tk -v
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 0c1a3da8ea1f0e024ebfd85c7532926f26c6bde5)
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/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
%
% clang-tk -w -O0 a.c && ./a.out
1
% clang-tk -w -Os a.c && ./a.out
0
%
% cat a.c
void printf();
int a = 1;
int *b = &a, *c = &b;
short d;
char e, f = 1;
static int *g = &a;
static int ***h = &c;
char *i = &f;
static char *j = &e;
long k;
short l[1];
short *m;
int main() {
int ***n = &c;
m = l;
for (;;) {
d = 0;
for (; d <= 1; d++) {
k = ***n;
if (m)
*g = *j = 0;
}
***n && (*i = 0);
if (**h)
break;
}
printf("%d\n", f);
}
%
```
Compiler explorer: https://godbolt.org/z/z8Gnz514T
I have reported another bug before :https://github.com/llvm/llvm-project/issues/58140, but I don't think they are the same after I did `opt-bisect-limit`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVU2PmzwQ_jXkMgIZEwg5cNhNtFVPPbRSj5W_CG6MHYHJbvvrOwaSkLz7VqrayAEznnnm8cx4zJ38UUUFmYZwtndGRWQfkaeI5iAMs4fYHyE-T8JRAGfV9dpZSIuEJAQiWjben_ooQ6MXH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