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

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 17 09:51:24 PST 2021


            Bug ID: 52535
           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
static int a = 1, b;
void foo(void);
int main() {
  for (unsigned d = 0; d < 19; ++d) {
    if ((char)a <= d)
      for (; b < 1; b++)
  a = 128;

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

clang-trunk -O3 -S -o /dev/stdout case.c
main:                                   # @main
# %bb.0:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        pushq   %rbx
        .cfi_def_cfa_offset 24
        pushq   %rax
        .cfi_def_cfa_offset 32
        .cfi_offset %rbx, -24
        .cfi_offset %rbp, -16
        xorl    %ebx, %ebx
        movl    $-128, %ebp
        jmp     .LBB0_1
        .p2align        4, 0x90
.LBB0_4:                                #   in Loop: Header=BB0_1 Depth=1
        addl    $1, %ebx
        cmpl    $19, %ebx
        je      .LBB0_5
.LBB0_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
        cmpb    $0, a(%rip)
        movl    $1, %eax
        cmovnel %ebp, %eax
        cmpl    %ebx, %eax
        ja      .LBB0_5
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
        cmpl    $0, b(%rip)
        jg      .LBB0_4
        .p2align        4, 0x90
.LBB0_3:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
        callq   foo
        movl    b(%rip), %eax
        leal    1(%rax), %ecx
        movl    %ecx, b(%rip)
        testl   %eax, %eax
        js      .LBB0_3
        jmp     .LBB0_4
        movb    $1, a(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 24
        popq    %rbx
        .cfi_def_cfa_offset 16
        popq    %rbp
        .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

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/20211117/59708368/attachment.html>

More information about the llvm-bugs mailing list