[llvm-bugs] [Bug 49436] New: dead code with division by zero not eliminated

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 4 04:40:04 PST 2021


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

            Bug ID: 49436
           Summary: dead code with division by zero not eliminated
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: theodoridisgr at gmail.com
                CC: llvm-bugs at lists.llvm.org

~/llvm-project/build/bin/clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
d2000b45d033c06dc7973f59909a0ad12887ff51)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/theo/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /opt/cuda, version 11.2

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

cat test.c
extern void foo(void);
int a;
static int b() { int c = 0; return a % c; }
int main() {
 if (a)
  if (b())
   foo();
 return 0;
}

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

~/llvm-project/build/bin/clang -O3 -S -o /dev/stdout test.c
        .text
        .file   "test.c"
        .globl  main                            # -- Begin function main
        .p2align        4, 0x90
        .type   main, at function
main:                                   # @main
        .cfi_startproc
# %bb.0:                                # %entry
        pushq   %rax
        .cfi_def_cfa_offset 16
        cmpl    $0, a(%rip)
        je      .LBB0_2
# %bb.1:                                # %if.then2
        callq   foo
.LBB0_2:                                # %if.end3
        xorl    %eax, %eax
        popq    %rcx
        .cfi_def_cfa_offset 8
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
        .cfi_endproc
                                        # -- End function
        .type   a, at object                       # @a
        .bss
        .globl  a
        .p2align        2
a:
        .long   0                               # 0x0
        .size   a, 4

        .ident  "clang version 13.0.0 (https://github.com/llvm/llvm-project.git
d2000b45d033c06dc7973f59909a0ad12887ff51)"
        .section        ".note.GNU-stack","", at progbits
        .addrsig

-- 
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/20210304/cc1919a8/attachment.html>


More information about the llvm-bugs mailing list