This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/65474] New: sub-optimal code for __builtin_abs


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65474

            Bug ID: 65474
           Summary: sub-optimal code for __builtin_abs
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wmi at google dot com

int foo(int x) {
  return __builtin_abs(x);
}

~/workarea/gcc-r221398/build/install/bin/gcc -O2 -S 1.c -o 1.gcc.s
        .cfi_startproc
        movl    %edi, %edx
        movl    %edi, %eax
        sarl    $31, %edx
        xorl    %edx, %eax
        subl    %edx, %eax
        ret
        .cfi_endproc

~/workarea/llvm-r224097/build/bin/clang -O2 -S 1.c -o 1.llvm.s
        .cfi_startproc
        movl    %edi, %eax
        negl    %eax
        cmovll  %edi, %eax
        retq
        .cfi_endproc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]