<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69293>69293</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong code at -O1/2/s on x86_64-linux_gnu since 669ddd1
</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>
Clang at -O1/2/s produced the wrong code.
Bisected to 669ddd1e9b1226432b003dbba05b99f8e992285b, which was committed by @aeubanks
Compiler explorer: https://godbolt.org/z/sGM1v4jd1
```console
% cat a.c
int printf(const char *, ...);
long a;
int b, c, e, g, i;
long *d, *h;
char f = -26;
int main() {
long j;
c = 0;
for (; c != 7; ++c) {
long k=0;
long l = k;
long **m = &d;
for (; f + i!=0; i++)
h = &l;
g = h != (*m = &j);
int *n = &b;
*n = g;
for (; e;)
for (; a; a = a + 1)
;
}
printf("%d\n", b);
}
%
% clang -O0 a.c && ./a.out
1
%
% clang -fsanitize=address,undefined a.c && ./a.out
1
% clang -fsanitize=memory a.c && ./a.out
1
% clang -O1 a.c && ./a.out
0
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF1vqzgQ_TXDixVkxnyEBx7yIfZp1cd9vDK2AbdgR9jctvfXr-w0NM32rnYj5MCcmXPOGDPcOT0YpRoojlCcE7760S6NG7ndjSvfTTrprHxvThM3A-Ge7J4ywBYBW0cui5WrUJL4UZHXxZqBCCtVCvQM9HBdj9op4UOOJWVZSykzVXcZYpkz7Chlsus4Lbq67veqrhH3RQd4Iq-jFiN55Y4IO8_aB4runUBOuVo7bl4cuZc52fmiJ7UQ9XaZ7KIWYAcyen9xwA6ALWA7WNnZyad2GQDbX6GDP_7MfubPMrtngpJeL2GNs5P6iGJBBPeEp-Ia0MaTy6KN7wH3IdUTMfKFAB6C_TRNAWtgx2v2FPaGb4-hOHYpwqLCMoRFfy0APMgQBjyMGxJVegLsTHZYfqGcuTaAe8CaQPURJyRSPW-JhIhYTO8ivQ3G98COAcQs4FV4AjwCHsUDY_hF1hdg53ueDZiixMsDtMFxkw5zTAIs5UPenZ0-WCD66ilIhftjvOqv1OONbfpGdYjgeOstbtKn_vP9q7oWhO0EPJhbSvcN6YYPv_evArRZvQN4XGI5jz1m_-goajzKQnX-CGynDxABCwnFycTbUzhbnw1tFYDF3WGOH_TuiYYjHToELEkK2PLUrv6al_2-rnfcaK9_KWBnLuWinAM8rUaqXhsl_xPpd1yzmu3y_r_Kn7J_SaePLdy-7kQ2TNas5olqsrKuCqxoQZOxYbVSSghZd0qKHIVCzFXVVx2tWZ5hmegGKbKMZhWtsorRtGKcCYZ5Jsu-2PcKcqpmrqd0mn7OYdwk2rlVNWWNNUsm3qnJxXmLaNQriWB4ccU5WZpQs-vWwUFOJ-28-2Tx2k-q-Wubs4_j2Bryti9_lPlu0mZ9-zGYlThthLoN3mRdpuZhKGo_rl0q7AzYBqWPv91lsc9KeMA2-nOAbfT_dwAAAP__tbShjw">