[Bug c/53110] New: GCC-4.7 generates stupid x86_64 asm

peterz at infradead dot org gcc-bugzilla@gcc.gnu.org
Wed Apr 25 10:13:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53110

             Bug #: 53110
           Summary: GCC-4.7 generates stupid x86_64 asm
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: peterz@infradead.org
                CC: hpa@zytor.com, torvalds@linux-foundation.org
            Target: x86_64


Created attachment 27233
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27233
small C file reproducing the issue

The below output of: gcc -O2 -S gcc-bug.c, shows gcc generating
pointless mask instructions, an and with all bits set.

    .file    "gcc-bug.c"
    .text
    .p2align 4,,15
    .globl    mult_u128
    .type    mult_u128, @function
mult_u128:
.LFB1:
    .cfi_startproc
    movq    %rdi, %r8
    movq    %rsi, %rcx
    andl    $4294967295, %edi
    shrq    $32, %r8
    shrq    $32, %rcx
    andl    $4294967295, %esi
    movq    %rcx, %rax
    movq    %rsi, %rdx
    imulq    %rdi, %rcx
    imulq    %r8, %rsi
    imulq    %r8, %rax
    salq    $32, %rcx
    salq    $32, %rsi
    imulq    %rdi, %rdx
    addq    %rsi, %rcx
    adcq    $0, %rax
    addq    %rcx, %rdx
    adcq    $0, %rax
    ret
    .cfi_endproc
.LFE1:
    .size    mult_u128, .-mult_u128
    .ident    "GCC: (GNU) 4.7.1 20120425 (prerelease)"
    .section    .note.GNU-stack,"",@progbits



More information about the Gcc-bugs mailing list