[llvm-bugs] [Bug 52347] New: Dead Code Elimination Regression at -O3 (trunk&13.0.0 vs 12.0.1)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 29 05:06:44 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52347

            Bug ID: 52347
           Summary: Dead Code Elimination Regression at -O3 (trunk&13.0.0
                    vs 12.0.1)
           Product: new-bugs
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: theodort at inf.ethz.ch
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

cat test.c
void foo(void);

static int a = 3, b, c[1], d;
void foo(void);

static void f() {
  if (a) {
    d = (char)c[0];
  } else
    b = 0;
}

int main() {
  a = b = d;
  f();
  if (b)
    foo();
}

12.0.1 at -O3 can eliminate the call to foo but neither 13.0.0 nor trunk can:

clang-12 -O3 -S -o /dev/stdout test.c
...
main:                                   # @main
        .cfi_startproc
# %bb.0:
        xorl    %eax, %eax
        retq



clang-trunk -O3 -S -o /dev/stdout test.c
...
main:                                   # @main
        .cfi_startproc
# %bb.0:
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    $d, %eax
        movl    d(%rip), %ecx
        movl    $b, %edx
        testl   %ecx, %ecx
        cmovneq %rax, %rdx
        movl    %ecx, b(%rip)
        movl    $0, (%rdx)
        cmpl    $0, b(%rip)
        je      .LBB0_2
# %bb.1:
        callq   foo
.LBB0_2:
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq

(13.0.0 produces identical code)

clang-trunk -v                                  
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
73453e7adecbcc7208ceb70d5e55086ffbd1de3a)
Target: x86_64-unknown-linux-gnu
Thread model: posix

This was introduced by
https://github.com/llvm/llvm-project/commit/ed9df5bd2f50b2199204cc6e50910ba52dd5e93e

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211029/95acff9a/attachment.html>


More information about the llvm-bugs mailing list