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

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 25 01:28:19 PDT 2021


            Bug ID: 52289
           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 test.c
void foo(void);

static int b;

static char a(char h, int i) { return h > i ? h : h << i; }
static long d(long h) { return h; }

int main() {
  char e = 0;
  short g = 0;
  e = a(b & 8, 7);
  g = d(e) * 20681;
  if (!(g ^ 1))
  a(0, 0);

13.0.0 at -O3 can eliminate the call to foo but trunk cannot:

clang-13 -O3 -S -o /dev/stdout test.c 
main:                                   # @main
# %bb.0:
        addl    $1, b(%rip)
        xorl    %eax, %eax

clang-trunk -O3 -S -o /dev/stdout test.c
main:                                   # @main
# %bb.0:
        pushq   %rax
        .cfi_def_cfa_offset 16
        movl    b(%rip), %eax
        addl    $1, %eax
        movl    %eax, b(%rip)
        xorl    %edx, %edx
        andb    $8, %al
        movl    $7, %ecx
        cmovnel %edx, %ecx
                                        # kill: def $cl killed $cl killed $ecx
        shlb    %cl, %al
        movsbl  %al, %eax
        imull   $1355350016, %eax, %eax         # imm = 0x50C90000
        cmpl    $65536, %eax                    # imm = 0x10000
        jne     .LBB0_2
# %bb.1:
        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.git
Target: x86_64-unknown-linux-gnu
Thread model: posix

This was introduced by

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/20211025/d9cef574/attachment.html>

More information about the llvm-bugs mailing list