https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119071
Bug ID: 119071
Summary: Miscompile at -Os
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: yunboni at smail dot nju.edu.cn
Target Milestone: ---
This code prints 0 at -O0/1/2/3 and 1 at -Os:
```c
int printf(const char *, ...);
int a, b;
int main() {
int c = 0;
if (a + 2)
c = 1;
int d = (1 + c - 2 + c == 1) - 1;
b = ((d + 1) << d) + d;
printf("%X\n", b);
}
```
Compiler Explorer: https://godbolt.org/z/3dn1drd9W
Bisected to
https://github.com/gcc-mirror/gcc/commit/a42ed1d9181d21d5cb02f131f641c0cf375eca9d