<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJztWNtu2zgQ_Rr5hZAgUaIuD36o7WaxQIDutvtu8CabrSS6IuVcvn6HlOzYSTebtEG33cYQLHNmeHhInqFGZlrczIM85tQiTo2MOApwmsd5BcYgXgXxm4AsvMde24CsAlxurd2ZIH0T4Au4NspuBxZx3UKjafaHW7jr9UfJLTRr1UgD96KKc1Lm8OsIiKtpEBjNX3xsG0ut4ohvaY9okC4m61b3FrEAL5G4M46hqoMZoCBdIXx07bUSqNYaSLuRDmYX2lLVjWYUFJMdIVXD9EvqYEakAz8En4dACPlQdGqpde8wnCVdoDCkZxjjAPzMhhDrJf10giE8KnuAPfaGi4BrOcUUS5T4aWCCknPGJ11lY-SdY1yo-OgPitW9fTg2eUO7TVjjCpOc5hnlScJrUnFJy6LkpUgYrUhaCJbVBKeOn-2H7pNjFL67BQDQVYc6bYGCalVHrURgdYsJPjZYdBzEyUb3mzCJozhKTrpHE5uT7_CZnzOEb50VCj-gUIP1Qsg9fBsr9HBIoLvFS5dCWqoaA6v9FlpmaFva30DjvRQDlwJRY2TLmhu3mwBz9EN7527npMeLmna0eAmnk4Qe_QRuClnsO0yQVcRrtYbc6S0k6pR1Pg4TxqLY5fchdDeY7We4g6un1-cIQtZrXtO1rmsjLUryo5u3O-Y7ZdglLPXKJb3a3SV9XH3spEO6XCziNb5PIjklca37ZuQggQMATr-Ow9GmcSSdsLztAHqC0er9RKn6Z0oQdHUSBAEnoxydZCTBHoeYosQXo_5tRju9O6w6f3zVy6O3l_bzYfr10PG17MTZXkZG3bolH8-_JToJC0_0ce8Y8PLcjcL0qveyvqfQF0nJh2fAL5ZsP4z8fnopfd3pvn-KpN4NdjfY5whpbHpiaC97o3SHkgw0HqNnl1QRBKCnzu645X_RfiOt0_B1ma_zLIQZd_qqCxvVDdfhphumuC1UIwK1WsjGRe-0UZMqfu9Aw00jxUr1zgW8bgW11FV0ut1BmdevOeVb6QzP2gPowA6KudBDJ9xjXyjhqoXflkuo7vzIUOnpbhp5ML1bF8XcinEoqS6mee34yZTwRZJESRR_HXSePQP8g2xgc-CgeVHU5ZFsOzRWufkCXORKNzhkAOqRqBRPYSm-R_ExrB_n8P-euTgO-XW5KOsU8zxJKMVJJkDhhKR5JmtRMJqRRHIieVoX2X-bi3lVY5xWLEswpRWuU1aSQpK4yggjQmS8LHHKaPKai79yLrqz2F1ooQzwc0vmHWMT6FrtiBKKcU7yrJAirbOskpUsZVXEEhc1kVWeCVBXQutpSXTbKut6sxu_A1ncqU-Kv_gJ8lRa_4vCMrocS6-s0fD2c1aavb7cvcDLXXTJjov7lDo7uhSPxr--8N31_aOXe6UHg7g_GlwGVGVFXb5mJY2LqkgIxwKnkog0xxgeZfDkKmVcyi8m_lM7vyb-T5EK31vWMzFPRZVWdEYHu9X9_M-B9gObDX0zf_b_3cqYwf_hTdI0KWbbOScg07pkcQLPngwTznPOREmxyATlRMwaymRj5gFZBBh38gp5CPgdkNXs2xmoOY4xjhO4CDwcq6jMs5RmMi0J5gmQA3VJWLUmcjgRlOCzfu4h2bAx4GyUsebOCbpXm05KTxgYWmUbOV-5UnUJpSp66__pVb7gQu_lppfGF9nU-vQ7vG-jvYmmwhu0MfOk557x31KzpY8>53317</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Dead Code Eliminiation Regression at -Oz (trunk vs. 10.0.1)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Quarub
</td>
</tr>
</table>
<pre>
`cat case.c #6069`
[case.txt](https://github.com/llvm/llvm-project/files/7906586/case.txt)
```c
static char a;
short b, d;
static int c = 2;
void foo();
int main() {
if (a == 2)
foo();
a = 9;
for (;; --a)
if (c)
break;
d = b = 9;
if ((5 <= b | 1) % 12)
;
else
c = 0;
}
```
`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -Oz` can not eliminate `foo` but `clang-llvmorg-10.0.1 -Oz` can.
------------------------------------------------
`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -Oz -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>
```asm
main: # @main
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
cmpb $2, a(%rip)
jne .LBB0_2
# %bb.1:
xorl %eax, %eax
callq foo
.LBB0_2:
movb $9, a(%rip)
movw $9, %ax
movw %ax, b(%rip)
movw %ax, d(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
```
</p></details>
------------------------------------------------
`clang-llvmorg-10.0.1 -Oz -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>
```asm
main: # @main
.cfi_startproc
# %bb.0:
movw $9, %ax
movw %ax, b(%rip)
movw %ax, d(%rip)
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
```
</p></details>
------------------------------------------------
`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -v`
<details ><summary>Output</summary><p>
```
clang version 14.0.0 (https://github.com/llvm/llvm-project.git f29256a64ac11cf59cea878c8d1ba9537db4f523)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/compiler_cache/clang-f29256a64ac11cf59cea878c8d1ba9537db4f523/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```
</p></details>
------------------------------------------------
`clang-llvmorg-10.0.1 -v`
<details ><summary>Output</summary><p>
```
clang version 10.0.1 (https://github.com/llvm/llvm-project.git ef32c611aa214dea855364efd7ba451ec5ec3f74)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/compiler_cache/clang-69f2239b412aa92f3b857e50945b5dd4c8823ba1/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```
</p></details>
------------------------------------------------
### Bisection
Bisected to: 5a2265647ed3f449e9e8e970e27f5e964db851af
Committed by: @nikic
------------------------------------------------
`clang-5a2265647ed3f449e9e8e970e27f5e964db851af -Oz -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>
```asm
main: # @main
.Lmain$local:
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
cmpb $2, a(%rip)
jne .LBB0_2
# %bb.1:
xorl %eax, %eax
callq foo
.LBB0_2:
movb $9, a(%rip)
movw $9, %ax
movw %ax, .Lb$local(%rip)
movw %ax, .Ld$local(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
```
</p></details>
------------------------------------------------
Previous commit: 989ae9e848a079715c2d23e5d3622cac9b48e08e
`clang-989ae9e848a079715c2d23e5d3622cac9b48e08e -Oz -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>
```asm
main: # @main
.Lmain$local:
.cfi_startproc
# %bb.0:
movw $9, %ax
movw %ax, .Lb$local(%rip)
movw %ax, .Ld$local(%rip)
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
```
</p></details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWN9v2zYQ_mvkF8KCRImS-OCH2m6GAQG6dXs3-Es2W0l0RcpN-tfvSMmOnXZZ0gVdu8YQLPPu-PG74x11MjfydhEViWAOCWZVLFCEsyIpKAijZB0lryKyD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