<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJztWltv2zYU_jXyCyFBJHV98ENtN1uBAu26vhu8yWYnS6pIuUl-_UhKVmS3yew07bYmhmCZPIeH37nyAtOa38y9JGREA0aUCBjwEE5wnplOL1x54SsvXjiKvtZevPJQttW6UR5-5aEr82yk3nY0YPXONMpyf3j5TVt_EkybZiFLocw7zcMkDXPzaxSI8mESM5t7WN-WlQbEw4u-ta8lB0Vdm8ntiEO3ZdoRWfXdwEuHfgDYlrSAAg-vQDiyAyOiBZYZLxxxeaAPrHCEA8ARMzHk1yMz8f0jRgBkYTnpSS_4BmQvXZ0oPDZZSaqNX6AcxQlJIsIgZEWcM0GyNGMZh5TkMU45jYoYYTuhbrvqL6u5_-7WCDAOrEBVayBKuZMV0QKYXovB0GinwTiJ9U_dbnwYBmEAJ8ODAc3k27_wcyThe7UC_p_Ar03vFRd78600r7tDpN4ZDy-50ESWqvfTUnW7HWlvTOOD4B0THBClxI6WN9bpRsxIN-3Gvo5B9w9Ru77HxRgevfrAx7MqRKEbMIjMA1bItdKk1SYjhvB2fCimNAhtIh1Ym05tP3s2Q-KWXh9L4KJYs4Ks66JQQgOYHJOH7mEkWgJ_wrGr99SJjaAl2ZnLkXhdt2U_pyDXA9n-cvTg7WIRruEZ2juV8MoY8-NWKvC2rhvwuyBctHbwSjR6a8jwOEHOEWo_y60seS_T4sG9PIBGJbRQ-kRFcqfip0pYOzldslMPoDOVM2leOQiW_6DZypnnVL3e5NaqxOV_3MrGVoFvGhefPf970gpT8kYzfDXvJWbtfQWA89abqhLtfT47tvL9sWINrUY7R6d2jr_bzvgeSPfH9tTx6Smg5IcAejCdDIGRsrQ5buvy5cGS_hDMXLAJ5hNUd5oc4xttvGtGG-Mp1uhHJdb9iT4xPh2NP6mkU6xwijWbluF_cmFTN2dW6WyktkJ_PkxYdBVbi4of1f5AyVsbrP2GZgkmbP5kPTnZNrjlrOkXMrdKumXwZEV7kiX86z3DM1ucz0_SRyyXDxbgu-C_pADjn7PQPVntOMpHfEk-_u9z63Hb4_05Ofau002nL8msvumAgb1olawrACOT9CG4-PAXGAZwrnZjYHwk7UZoG33XWbJOIt9oXNVfKr-UVXftb6pu4Nu2JjrBruaitNxNreQQFW8qk9RlKfhKulQyuG450cSePetdYw6k7ZoRthW24yIfmAH0EDFXdVdxe27iktvj1m_LpckdNzPRxm7DzJ1qrV0ktRZjzHwPejVsohK6gjCAQfg40Ul0gfA_RWmcYyrvk0pdjmB3Xaml1deIC-zZ11TdJHqIC6OBDaMTiA_J-u-shj8zF_spH5eLosCIJRASgmDETYTHMU4iUfCUkiiGgsWC4SKN_t1cTPICIZzTCCJCclRgmsWpiMM8imnMecSyDGFK4EsuPudctLXYPmAhlcFnTeYIfdPA1bUFijDKIc2zBLOMFCnhOMpYRFKexTzjaRbxIssEHbYfy3q3k9qOpjfOA3bDeO1_7sgtqZ68jJyL7Rlut3_eXdi558df5C7s5SrsVNzzuAp7uQn75W_Czr3Vf7kJe8Si_b4Ve1l3CjC3RXBbCxHnUcjM0RHGMKVm40wxjCJYQJyZrWtBQkTSIqffXvvPHPwM1_6Xq7aXq7Y-eWd8jnmOczIjnd7W7fyPjrQdnXVtOb_4fwhSqc79ESHGGGaz7TyM4oQIyBMR5ZRmUCScUpxxlOQ5ZGk4KwkVpZp78cJDqBJfgBNhfnvxavb9COQchQiF0DxJiGMUIFEUgoYsR4JELM1NDgljtTKwcoK63czauRNJu40yxFIqre6IJrvlphLCATYItdSlmK_swXxpDubg9fDHAHuN8EFsWqHcjQLRrsYcLhfBXgXDLYMJoJnDPHeA_waYguWg>53318</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Dead Code Elimination 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 #6398`
[case.txt](https://github.com/llvm/llvm-project/files/7906709/case.txt)
```c
int a;
void foo();
int main() {
  char b = 0;
  for (; b <= 0; b = 1)
    for (; a >= 0; a--)
      if (b)
        foo();
}
```
`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   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset %rbx, -16
        movb    $1, %bl
        xorl    %eax, %eax
.LBB0_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
        testb   $1, %al
        jne     .LBB0_8
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
        movl    a(%rip), %eax
.LBB0_3:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
        testl   %eax, %eax
        js      .LBB0_4
# %bb.5:                                #   in Loop: Header=BB0_3 Depth=2
        testb   $1, %bl
        jne     .LBB0_7
# %bb.6:                                #   in Loop: Header=BB0_3 Depth=2
        xorl    %eax, %eax
        callq   foo
        movl    a(%rip), %eax
.LBB0_7:                                #   in Loop: Header=BB0_3 Depth=2
        decl    %eax
        movl    %eax, a(%rip)
        jmp     .LBB0_3
.LBB0_4:                                #   in Loop: Header=BB0_1 Depth=1
        movb    $1, %al
        xorl    %ebx, %ebx
        jmp     .LBB0_1
.LBB0_8:
        xorl    %eax, %eax
        popq    %rbx
        .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:
        movl    a(%rip), %eax
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
        testl   %eax, %eax
        js      .LBB0_3
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
        decl    %eax
        movl    %eax, a(%rip)
        jmp     .LBB0_1
.LBB0_3:
        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: 23291b9863c8af7ad348c4a7d85d8d784df88eb1
Committed by: @max-quazan

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

`clang-23291b9863c8af7ad348c4a7d85d8d784df88eb1 -Oz -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>

```asm
main:                                   # @main
        .cfi_startproc
# %bb.0:
        pushq   %rbx
        .cfi_def_cfa_offset 16
        .cfi_offset %rbx, -16
        movb    $1, %al
        xorl    %ebx, %ebx
.LBB0_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
        testb   $1, %al
        je      .LBB0_8
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
        movl    a(%rip), %eax
.LBB0_3:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
        testl   %eax, %eax
        js      .LBB0_4
# %bb.5:                                #   in Loop: Header=BB0_3 Depth=2
        testb   $1, %bl
        je      .LBB0_7
# %bb.6:                                #   in Loop: Header=BB0_3 Depth=2
        xorl    %eax, %eax
        callq   foo
        movl    a(%rip), %eax
.LBB0_7:                                #   in Loop: Header=BB0_3 Depth=2
        decl    %eax
        movl    %eax, a(%rip)
        jmp     .LBB0_3
.LBB0_4:                                #   in Loop: Header=BB0_1 Depth=1
        movb    $1, %bl
        xorl    %eax, %eax
        jmp     .LBB0_1
.LBB0_8:
        xorl    %eax, %eax
        popq    %rbx
        .cfi_def_cfa_offset 8
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
```
</p></details>

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

Previous commit: 2e5940cf291517b3f7b31441f13812afa02a7f9b

`clang-2e5940cf291517b3f7b31441f13812afa02a7f9b -Oz -S -o /dev/stdout case.c`
<details ><summary>Reduced assembly</summary><p>

```asm
main:                                   # @main
        .cfi_startproc
# %bb.0:
        movl    a(%rip), %eax
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
        testl   %eax, %eax
        js      .LBB0_3
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
        decl    %eax
        movl    %eax, a(%rip)
        jmp     .LBB0_1
.LBB0_3:
        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/eJztWltz2ygU_jXyCyONAKHLgx8au9ntTGfa7fY9w002XVlSBXKT_PoFJCu222TtNO3uNvFobMM5nBt85wA2a8TNPEhjTg3gVMuIgwDhFBe57QziZRC_CsiFp5hrE5BlgPK1Ma0O8KsAXdpnpcy6ZxFvNrZRVdvdR9h2zSfJjW2WqpLafmZFnGZxYb9NAlExKrHa_MOHtqoNoAG-GFrbRglQNo1V7kbsuh3Thqp66AZBNvYDwNe0AwwEeAniiR1YER1wzPjCExc7-sgKJ3MAOGCmlvx6YqZheMAIgCodJzvqBd8wOciWRw5PTV7RehWWqEAkpWlCOYS8JAWXNM9yngvIaEFwJlhSEoSdQtP19V_O8_DdrRVgJ7AGdWOArNRG1dRIYHudDZbGegMmJW5-mm4VwjiKI7g3PBqt2XsPz3wdSPher0D4Jwgb23sp5Na-ayOafrdS74KHF0Iaqio9zNNC95sN7W5s44MUPZcCUK3lhlU3btKtmIlu2637ODR6eKjeDD1-jeFpVh94Bc6FJPYDRpFFxEt1pQ3tjEXEuLw9HyKMRbED0o617fX6c-AQQjp2fShByPKKl_SqKUstDYDpIXnsHkeiBQj3ODbNlnmxCXQkp7maiNdNVw06Jb0eye6bp0dvLy7iK3iC994lvLTB_LhWGrxtmhb8LqmQnRu8lK1ZWzI8BMgpQt1rsVaVGGQ6e_AgD6DJCSO1OXKR3rn4qZYuTt6X_HgG0InOWZjX3gTHv_Ns6cNz7N4QchdV6vFPOtW6LPDN4OKT9b-nnbQpbwrDV3rPCeswVwD42XpT17K7b84Oo3z_WnGB1lOck-M4k--OM77HpPvX9v7EZ8cGpT_EoAfhZAmcVpXDuMvL5y-W7IfYLCTfs_nIqjtPDu2bYrxppxjjfVuTHwWs-4G-F3w2BX8vk-7bCvdtzffT8D9NYdu0J2bpfKJ20nzeKSz7ml_JWhzk_kirW7dYhw3NAuyxhXv15Gjb4MtZOxQyXyV9GTy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