https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77980
Bug ID: 77980 Summary: Regression in GCC-7.0.0's optimizer. Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ishiura-compiler at ml dot kwansei.ac.jp Target Milestone: --- We compiled a program (A.c) by GCC-7.0.0 and clang-3.8.0 with -O3 option. clang-3.8.0 performed better optimization than GCC-7.0.0. (A.c) #include <stdio.h> int x1 = 0; unsigned int x2 = 1; int main () { int t1 = x1*(1/(x2+x2)); if (t1 != 0) __builtin_abort(); return 0; } /* +---------------------------------------+--------------------------------------+ |gcc-7.0.s(gcc-7.0.0 A.c -O3 -S) |clang.s(clang-3.8.0 A.c -O3 -S) | +---------------------------------------+--------------------------------------+ |main: |\t.type\tmain,@function | |.LFB11: |main: | | .cfi_startproc | .cfi_startproc | |\tmovl\tx2(%rip), %eax |# BB#0: | | xorl %edx, %edx | | | leal (%rax,%rax), %ecx | | | movl $1, %eax | | | divl %ecx | | | imull x1(%rip), %eax | | | testl %eax, %eax | | | jne .L7 | | | xorl %eax, %eax | xorl %eax, %eax | | ret | retq | |.L7: |.Lfunc_end0: | | subq $8, %rsp | .size main, .Lfunc_end0-main| | .cfi_def_cfa_offset 16 | | | call abort | | | .cfi_endproc | .cfi_endproc | |.LFE11:\n |\n | | .size main, .-main | .type x1,@object | | .globl x2 | | | .data | | | .align 4 | | | .type x2, @object | | | .size x2, 4 | | |x2: | | | .long 1 | | | .globl x1 | | | .bss | .bss | | .align 4 | .globl x1 | | .type x1, @object | .align 4 | | .size x1, 4 | | |x1: |x1: | | .zero 4 | .long 0 | | .ident "GCC: (GNU) 7.0.0 20...| .size x1, 4 | |\t.section\t.note.GNU-stack,"",@prog...|\n | | | .type x2,@object | | | .data | | | .globl x2 | | | .align 4 | | |x2: | | | .long 1 | | | .size x2, 4 | | |\n | | |\n | | | .ident "clang version 3.8....| | | .section ".note.GNU-...| +---------------------------------------+--------------------------------------+ /* using built-in specs. COLLECT_GCC=gcc-7.0 COLLECT_LTO_WRAPPER=/home/kota/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper target: x86_64-pc-linux-gnu configure woth: ../gcc/configure --prefix=/home/kota/opt/gcc --program-suffix=-7.0 --disable-multilib --enable-languages=c thred model: posix gcc version 7.0.0 20161013 (experimental) (GCC) using built-in specs. clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7.4 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.0.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 */