<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJztWVuT0zYU_jXOi8YeWZId-yEPJGFbZpihBd4zujkx9Q1LDrv8-h4pTuJsYdkFSim7Hk-sy9HRd67WiUWrbhZBiiW3SHKjI4kCQpMcxzAY4HWAnwXJ0s_Yaxsk64BkO2s7E9BnAbmCe1va3SAi2dbQqar98RF2fftOSwvdoqy0gec8xyljMbRODEk-bgK7-Vse-mbX9haJgC4PfbnjPZIBWSF1GjOW21KisrFIo4CuUXya2relQkXbAlrXdNtMOcEwd2Mk83wLx9e3tjCKgvkS9doOfYMK0MYSRukSRtcHBm6_mpcNrB6pD-MINuyRGwVq6fY7Cofg0sDI3fREXTrmmb6gAlRZGCqH50Avp9CBS2X0dEeEDkZAb2pegZIt6lpjSlFp1Ay10L3HtDuTD40pt41WaOc1RmI2ZxlNk3iyyVSQ22IcYbvlK1D45RwaDSEuuH0KtrsOEPAt2gs1-m2Oph0XOB3tnIb87rcBoNHsl3rzmjoacNI8N47-d-rKijfbsCA5SVKeMi7jWBZJLjXP5pnMVCx4ntC5EqxICHWAbT80fzmXCF9RYADx1KCmBeesyrpsuAUVpNihgzkxWHTaxIVL22_DmEY4wpPl0Yhm8hs-8Lrg8K1SofANClvnc0rv4ddY1Q7HxHFWHl0pbXlZGbDXc-iZoa55fwOd11oNEryPG6NrUd046wKb0zz0O_e4BH24uakPIz746MTin70CJwLDfsHIMo9kUW4gdfQWEtSYbTwdSYSIsMtrR9JuMLv38ISpnl9fclC62MiCb9qiMNqiOD1Ny7oTfhHDPq94Z0z6sjsnO5y_047Ry-Uy3pAz447wCsITmswtxdf5qNIDZXwPqb0odA1KfLsrDXrRNJAEXrZth37XXOnesVjrzu6AKD7DqbsTnni6JZnqAySrJpLpL0nGbmuXTrlxpUY9hfEhsX-KXd3uR6r489q8bvsDsESDnXzy9K2TIdvuaEd5tx2z0yy8Ad7f2zLsX7PMl5wN0r4TzaWVu8amBmZH5MXQyI1uVDw1S2TKj86Eh1fcCk3Iwkkg3cqXPo67QwT79ODj_1Yof5fc9c9k-ciy0q-bX35gRjhH9_80DL7uFb6_Tzi8Gmw32IcEwXiydsDQXvembBsUMx-fD64XIiBA95XuZPK3vN9q65zvOks3KQtB4qb90IRV2QzX4bYZRrpdD26K6lbpylHDcbkcveJFA_EHh2i1Lr0XA66PilvuypW27qCG6TeSy512Aw-yASwQR4-5aodGubOdKpU7Ev62WkEF43eGaqZtxp0H0zu9lMJpTIKPX41ydXIiErmK4yiO8NexTtkDmL_RFRgHkuR35bo6ga2HypZOXmAXuZM7JMiU3UVFyUhGyS2Id_H6eV5cPzIW6TfEopqLNM0F5RRTlshCKkEKpQkv0oJlnDORs4wl6r-NRa0YpppJQXQic5nGihRCMCa4xlQmKaYkx6KIn2LxMceiy8XuRsvSAD6nMj9x6AJc2zqgUrOC51SJTJAEUjvN8oLMC8GpnhORiDmWsZi7w4pXSVvXpXWrxY23AMO8sW0T8oI33NzAofR755L7AnyEx-Onov2paH8q2n-OauWPXu_LdjBI-hTplEUyQeHNPZcFvK9FITPCSJ7jbM7njOB5RiVROY3jKZtT2rvv4keY9n7dBPYL_yswUwsKDpvzGR_sru0Xfw68H8Rs6KvFg7-ylcYM_jNbQmmcznYLmgpZxJxCZQonBVrkmAmoSSlO8oxRhWcVF7oyiyBZBoQ0-gPyLKAdJOvZtyMoFwQTgmO4E4YTGmktRCYVcSUzLVIF7q5Ba1Xk-ERQG836hWcphq2Byao01pwnIRDdtyvtAQNCW9pKL9auhlhBDYGej99ZXMXzWm97bXzxw61PB8f_QdDeRGNBBK4x85gXHvDf9De1eg>53316</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Dead Code Elimination Regression at -O3 (trunk vs. 13.0.0)
</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 #5901`
[case.txt](https://github.com/llvm/llvm-project/files/7906441/case.txt)
```c
short b;
char c, d;
static int e = 1;
void foo(void);
char(a)(char f, char g) { return f + g; }
int main() {
for (; c;)
e++;
if (e)
a(--d, ++c);
else {
// Smallest possible number for h
unsigned h = 2147483651;
for (;;)
if (h < 1)
e = b;
else {
h = 0;
for (; h <= 1; h = a(h, 1))
foo();
}
}
}
```
`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -O3` can not eliminate `foo` but `clang-llvmorg-13.0.0 -O3` can.
------------------------------------------------
`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -O3 -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 $0, c(%rip)
je .LBB1_2
.p2align 4, 0x90
.LBB1_1: # =>This Inner Loop Header: Depth=1
jmp .LBB1_1
.LBB1_2:
cmpl $0, e(%rip)
je .LBB1_4
# %bb.3:
addb $-1, d(%rip)
movb $1, c(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.p2align 4, 0x90
.LBB1_4: # =>This Inner Loop Header: Depth=1
.cfi_def_cfa_offset 16
callq foo
callq foo
jmp .LBB1_4
.Lfunc_end1:
.size main, .Lfunc_end1-main
```
</p></details>
------------------------------------------------
`clang-llvmorg-13.0.0 -O3 -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>
```asm
main: # @main
.cfi_startproc
# %bb.0:
cmpb $0, c(%rip)
je .LBB1_2
.p2align 4, 0x90
.LBB1_1: # =>This Inner Loop Header: Depth=1
jmp .LBB1_1
.LBB1_2:
addb $-1, d(%rip)
movb $1, c(%rip)
xorl %eax, %eax
retq
.Lfunc_end1:
.size main, .Lfunc_end1-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-13.0.0 -v`
<details ><summary>Output</summary><p>
```
clang version 13.0.0 (https://github.com/llvm/llvm-project.git d7b669b3a30345cfcdb2fde2af6f48aa4b94845d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/compiler_cache/clang-ed403e4cb2e5c9c61d2fbb44bae03c5603290bf1/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: ce4fa93db8b2511c389f27fba3e72b5b70c1b7db
Committed by: @anton-afanasyev
------------------------------------------------
`clang-ce4fa93db8b2511c389f27fba3e72b5b70c1b7db -O3 -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 $0, c(%rip)
je .LBB1_2
.p2align 4, 0x90
.LBB1_1: # =>This Inner Loop Header: Depth=1
jmp .LBB1_1
.LBB1_2:
cmpl $0, e(%rip)
je .LBB1_4
# %bb.3:
addb $-1, d(%rip)
movb $1, c(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.p2align 4, 0x90
.LBB1_4: # =>This Inner Loop Header: Depth=1
.cfi_def_cfa_offset 16
callq foo
callq foo
jmp .LBB1_4
.Lfunc_end1:
.size main, .Lfunc_end1-main
```
</p></details>
------------------------------------------------
Previous commit: 28b3cac7cf403bfc824299087a7420783c2d9311
`clang-28b3cac7cf403bfc824299087a7420783c2d9311 -O3 -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>
```asm
main: # @main
.cfi_startproc
# %bb.0:
cmpb $0, c(%rip)
je .LBB1_2
.p2align 4, 0x90
.LBB1_1: # =>This Inner Loop Header: Depth=1
jmp .LBB1_1
.LBB1_2:
addb $-1, d(%rip)
movb $1, c(%rip)
xorl %eax, %eax
retq
.Lfunc_end1:
.size main, .Lfunc_end1-main
```
</p></details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVmT0zgQ_jXOi8ouW5KvhzyQhNmliip2gfeULidmfWHJYYZfvy3ZSZxZGGaAZVlmXK5YR6v769NSzFt5s_SSUDCDBNMqEMjDJM7DCAa9cOOFz7x45WbMtfHijYezvTGd9sgzD1_BvSvNfuCBaGvoVNXh-PC7vn2nhIFuUVZKwzPNw4TSCFonhjifhIA0d4uxr_dtbxD3yGrsiz3rkfDwGsnTmDbMlAKVjUEKeWSDotPUoS0lKtoW0NqmFTPnBMPMjuHM8S0sX9fawSjy0hXqlRn6BhVgjRWMkhWMbkYGVl7NygZWT9TjOAKBPbKjQC2svKNyCC4FjOxNTtSlZZ6pCypAlfm-tHhGejGHDlwqreYSERqdgN7UrAIjG9S1Wpe8UqgZaq56h2l_Jh8aXe4aJdHeWQxHNKUZSeJoJmSuyG01jrDt8jUY_HIOTY7gF9w-BdteI4TwFu2FGZ2Yo2unBdZGe2shJ_02ADS5_dJuzlJHB86a58Yx_k5dUbFm5xc4x3HCEspEFIkizoViWZqJTEac5TFJJadFjIkFbPqh-cuGhP-KAAPIpwY1LQRnVd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