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

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 22 09:05:14 PST 2021


            Bug ID: 52580
           Summary: Dead Code Elimination Regression at -O3 (trunk vs
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            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 case.c
void foo(void);

static int b;
static int *e = &b;
static char a(char f) { return f < 0 ? f : 0; }
static char c(unsigned char f, int g) { return f >> g; }

int main() {
  int h = *e;
  *e = a(h);
  if (c(h, 1)){
    if (h)
      *e = 0;
  c(0, 0);

trunk cannot eliminate the call to foo but 13.0.0 can:

clang-13.0.0 -O3 -S -o /dev/stdout case.c
main:                                   # @main
# %bb.0:
        xorl    %eax, %eax
        .size   main, .Lfunc_end0-main
                                        # -- End function

clang-trunk -O3 -S -o /dev/stdout case.c
main:                                   # @main
# %bb.0:
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    b(%rip), %eax
        xorl    %ecx, %ecx
        testb   %al, %al
        movsbl  %al, %edx
        cmovsl  %edx, %ecx
        movl    %ecx, b(%rip)
        cmpb    $2, %dl
        jb      .LBB0_4
# %bb.1:
        testl   %eax, %eax
        je      .LBB0_3
# %bb.2:
        movl    $0, b(%rip)
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        .cfi_def_cfa_offset 16
        callq   foo
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8

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

Started with

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/20211122/b62c10e6/attachment.html>

More information about the llvm-bugs mailing list