<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56046>56046</a>
        </td>
    </tr>

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

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```c
static short a;
static int b;

void foo(void);
void bar9_(void);
int main() {
    char c;
    b = a = 23;
    for (; b <= 1;)
        a = 1;
    bar9_();
    c = a >= 18 || 2 > 2 >> a ? 1 : 1 << a;
    if (c == 0)
        foo();
}
```
`llvm-4c2bccfda3892ae13e97b6bfdbc99ec8cf5d095d (trunk) -O3` can not eliminate `foo` but `llvm-llvmorg-14.0.4 -O3` can.

Target: `x86_64-unknown-linux-gnu`

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

`llvm-4c2bccfda3892ae13e97b6bfdbc99ec8cf5d095d (trunk) -O3 [-emit-llvm] -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
        movb    $1, a(%rip)
        callq   bar9_@PLT
        xorl    %eax, %eax
        cmpb    $0, a(%rip)
        movl    $23, %ecx
        cmovel  %eax, %ecx
        movl    $2, %eax
        shrl    %cl, %eax
        addl    $-8, %ecx
        cmpw    $9, %cx
        ja      .LBB0_3
# %bb.1:
        cmpl    $2, %eax
        jb      .LBB0_3
# %bb.2:
        callq   foo@PLT
.LBB0_3:
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
```
</p></details>


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

`llvm-llvmorg-14.0.4 -O3 [-emit-llvm] -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
        movb    $1, a(%rip)
        callq   bar9_
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
```
</p></details>

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

### Bisection
Bisected to: c0e06c7448a2dd16796e210a66de68f269363e31
Committed by: @nikic
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVkuTmzgQ_jX4ooISQmA4cIjtzClV2crm7hKSsDUBRJDwzOyv35bADJ6ZzNYme9oKpRJSP75uqR9QafFUBhmeBg_wIcAfjGVWcWTOerCIBcnuhqw6i6qFOM0XrQSqtQ5I7pYBKRYBz6rYUBzfYDqslqkOWEBGwXamI3j4mQ2IL6KOVKEgOSDmZ5LcsGo9IIeS7LzU3onETgKsLULumbTjW9zZvbVr3oXF3kevlIOHexiIONI0u4WTuEMxzB_8DNb3q4tzUKp27nlAB4Vf-TXd3tqDYHuYF9f4LNumubQh5aTivBYsyQvCZJzIYltlVS0qXhSS57xOBS5S4QzbYey-uSsOPyegjzjrUKctko1qVcesREB1LgCvGi262nCTHk5hTCMc0ZV2tA7_VzacpHWnB-5jnh0zGoK9Tj90YaO68TE8deOz_34O_-Wz1v3VG0BBugtlq6w_X5AeUPgnCjWI3Ql5gdlYoeEWODMy4s-OJ3shLVONmQK_N2PbsuEJNl-kGLkUiBkj26p5cjkAMAsf9r173R5iGsy0E8VXQrJkxDtPQOAMFHuFGbKIeK2OUKOD7Qc9V7KXI2lVRRiAF9F-NOfv8AbWwB5vEYSsj7xmR13XRloUZwu71ZfKK9E4IC6_Xbqmg-qXXAYuZ03joKeSoviPT18X3qMemsmqBKsAMa8W3bafDeAfGwAvJhAKHWDG4GsMfZGvrawkVgBv-GDOVx958wabCTErh_mb1vuHiV3M3BXznrk7_rTb4WPyMjzxOjyA8o6H99WPYcgNzBwKV9arQFxVV5L_FJhe99d04e-nS75w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