<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJztWdtu2zgQ_Rr5hbBAkdTtwQ-13SwKFOhuu-8Gb7LV6uKKlOv263dIy4qcZNOkLbrdJoJgiZzhmTPkzISMRKs-L4IES26R5EaHEgWExnmWQGeA1wF-EcRLL7FHG8TrgGQ7a_cmoC8CcgX3trS7XoSyraFRVYfzY77v2vdaWmgWZaUNPNMcpyRP4G0EJPlgBKz5W57axna9tChIl6c2QqbcNlohEdCxS-54h-Sko28GLWCH8rsEJ1E0EQ2CD64_HfuDdI302Dq0pUJF24Lz7tWxPouqttlCN3d9JHMtVARkhfwbSHLnA-q07bsGFWD9JcoJoTQlmCZZzNI0znCK5mgLsiuv8QLG0SWMW59MlI1FNS8bwB_wztzBaoadNTylhFAJMCTToRrnF8GlQwHoa1C-qRmQyEERB-VDIH6JIm_tAuA0A1NTI8dx_camrHiznRckJ3HCE8ZlFMkizqXmWZrJTEWC5zFNlWBFTKhjAUvefHAezt8QAIB4bFDTWqSrsi4bbjWCXscBZKK3aDTiwq3ttvOIhjjEk-HhwGbyO3_kdYHwvV6h-Ts0b6H3SukD_Bqr2v6ceNeTR1dKW15WxoULtExf17z7DI23WvUSopUbo2tRQdfKwYxyaO_d45L06eamPvX4WKJ-Rb9yBc4Fhv2AATIPZVFujOWdhQQfstXrkViIELu6cFbd92b3EZ4g6vjxEkHpYiMLvmmLwmiLomQU1-3hy6cKXnRAlrEPuLgr9z4YV86MnmBZbWzlTbA4ItcK_-5PWdenLDgSjEec99oRe71cRhty06do6hOwG-z5xNMX_LzSGeVykBEfB5fYHS5Np-fYdqdJYz4Fb8nfN9dc45tc6dQsb9SANCd3AAErLsygcbsoJech8njX7KVXF9cYc7ms9-dFl8e7-N9Dn03pS15VDsml_GRm46kOTNZpOXxU3I6PfTslc18EZqMUivXHs8Gib-RGN-oiBkJTfnFOnIryCk3U5pNcuVESfaruT0nqK4BP8RvZ-kPK0-16-MQKz29YQr4W6P_7oP22v6mHhwTvm97ue_uYkD01PTF00J0p2wZFzGfTozfAISigh3o3hsDfvNtq67LlmCWbhM3B46b91MyrsumP823TD3q7TnOF6lbpymnvW1MOUfGqgWypKq3WZedEwOuL4pa7_Xdb72FT3m0klzvtOh61BjBAnCPmqu0b5TZbqlRuj_bHaoXKk2VuYd4Gy73p3LyUws2YlPA7-LWXE5fIVRSFUYi_DTphjwB_pytYHChpPxR1NZKt-8qWzl-AC92GGcoZQN2jRcmgRskNivdh_Tp_Zn5mLtLvyEWViiTJBeUUUxbLQipBCqUJL5KCZZwzkbOMxeq_zUWtGKaaSUF0LHOZRIoUQjAmuMZUxgmmJMeiiJ5z8SnnoqvF7kbL0gA_N2VecGoCXds6oiKOmWaRJiqKRZolaU5oJGiOdcxoFFONIcZ0oYcpaeu6tG60-OxXgOHXWmjYOr599cOryEOpPcFt7PP5-fn8_Hx-_mnF9M9OH8q2N0j6-udSPIsYg40wYzJisY5UjnmEZcqgKkXwzlghiqyQ4s7K9tDBT7Cy_YY16lc7oM_Ugqqc5nzGe7tru8VfPe96Meu7avHoLzilMb3_hBNTSvBst8CSCoUJxWlCRZEqXOiUcaESHkmZkmRWcaErswjiZRCvZ99vslwQTAiO4E5JRlmYJ2Apx7iIWSSKREA0apimKnQ4IZxLZt3CQ4p-a0BYlcaaayHkifvwo88MbWkrvVi7_fsK9u_o5fDRwZ023uptp40_eHDrs_X8Pwh0MOFwGIHYmHnOC0_4H0VdQ_4>53320</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Dead Code Elimination Regression at -O2 (trunk vs. 13.0.0)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Quarub
      </td>
    </tr>
</table>

<pre>
    `cat case.c #5986`
[case.txt](https://github.com/llvm/llvm-project/files/7907296/case.txt)
```c
struct {
  signed b;
  char c;
  unsigned : 9;
  unsigned d : 1;
  signed k: 7;
} e;
void foo(void);
long(a)(long f, long g) { return f > 9223372036854775807 - g ? f : g; }
int main() {
  a(0, 0);
  if (e.d)
    e.b = 0;
  if (!a(2, e.c ^ 128))
    foo();
}
```
`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -O2` can not eliminate `foo` but `clang-llvmorg-13.0.0 -O2` can.


------------------------------------------------

`clang-f29256a64ac11cf59cea878c8d1ba9537db4f523 (trunk) -O2 -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
        movzwl  e+5(%rip), %eax
        testl   $512, %eax                      # imm = 0x200
        je      .LBB1_2
# %bb.1:
        movl    $0, e(%rip)
.LBB1_2:
        movsbq  e+4(%rip), %rax
        xorq    $128, %rax
        jne     .LBB1_5
# %bb.3:
        andq    $-2, %rax
        movabsq $9223372036854775806, %rcx      # imm = 0x7FFFFFFFFFFFFFFE
        cmpq    %rcx, %rax
        je      .LBB1_5
# %bb.4:
        callq   foo
.LBB1_5:
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq
.Lfunc_end1:
        .size   main, .Lfunc_end1-main
```
</p></details>

------------------------------------------------

`clang-llvmorg-13.0.0 -O2 -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>

```asm
main:                                   # @main
        .cfi_startproc
# %bb.0:
        movzwl  e+5(%rip), %eax
        testl   $512, %eax                      # imm = 0x200
        je      .LBB1_2
# %bb.1:
        movl    $0, e(%rip)
.LBB1_2:
        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: b554e41e2d15b78679231b390e543153e05c9efe
Committed by: @LebedevRI

------------------------------------------------

`clang-b554e41e2d15b78679231b390e543153e05c9efe -O2 -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
        movzwl  e+5(%rip), %eax
        testl   $512, %eax                      # imm = 0x200
        je      .LBB1_2
# %bb.1:
        movl    $0, e(%rip)
.LBB1_2:
        movsbq  e+4(%rip), %rax
        xorq    $128, %rax
        jne     .LBB1_5
# %bb.3:
        andq    $-2, %rax
        movabsq $9223372036854775806, %rcx      # imm = 0x7FFFFFFFFFFFFFFE
        cmpq    %rcx, %rax
        je      .LBB1_5
# %bb.4:
        callq   foo
.LBB1_5:
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq
.Lfunc_end1:
        .size   main, .Lfunc_end1-main
```
</p></details>

------------------------------------------------

Previous commit: 81441cf44c145e1d90a10c743e0190a44fbf8fcb

`clang-81441cf44c145e1d90a10c743e0190a44fbf8fcb -O2 -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>

```asm
main:                                   # @main
        .cfi_startproc
# %bb.0:
        movzwl  e+5(%rip), %eax
        testl   $512, %eax                      # imm = 0x200
        je      .LBB1_2
# %bb.1:
        movl    $0, e(%rip)
.LBB1_2:
        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/eJztWVmP2zgM_jXOixBD1uHjIQ9N0lkUKNDddt8DXU7c-kgtOU3765dyHI8zMzudaYtutzOGYVsiRX6kSIaOZaM_L4IYK-GQEtaECgWE8iyNYTLA6wC_CPiyp7ijC_g6IOnOub0N6IuAXMG5Ldyuk6FqKhiU5eF8m-_b5r1RDoZ5URoL9yTDCclieBoFkmxQAtr6U53G1rWdcihIlqcxQrbY1kYjGdBxSu1Ei9RkoqsHLkCHsrsIJ1I0IQ2ED34-GeeDZI3MODo0hUZ504Dx_tGjPpPKpt7CtPBzJPUjlAdkhfonoGTeBtQa17U1ykH7S5QRQmlCMI1TzpKEpzhBc7QF2lXP8QLW0SWsW59UFLVDlShqkD_IO2MHrSn22vAUEkIFiCGpCfXoXwSHCSVIXwPzTc6ARF4U8aL6EOAvUdRruxBw8sBU1Yhx3L9xqEpRb-c5yQiPRcyEiiKV80wZkSapSnUkRcZpoiXLOaEeBWx5_cFbOH9DQADEY43qxiFTFlVRC2cQzHoMQJOdQ6MSH25Nu51HNMQhniwPBzST6_yRx4WE77UKzd-heQOzV9oc4Gqdbrpz4l07j660caIorQ8XGNmuqkT7GQZvje4URKuw1l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