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

             Bug #: 51954
           Summary: __int128_t negation can be optimized
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: svfue...@gmail.com


__int128_t neg(__int128_t x)
{
    return -x;
}

Compiles into with -O3 :

mov    %rdi, %rax
mov    %rsi, %rdx
neg    %rax
adc    $0x0, %rdx
neg    %rdx
retq

Note how the last three instructions before the return are dependent on each
other.  This can be  slightly improved with slightly more inter-instruction
parallelism:

mov    %rdi, %rax
mov    %rsi, %rdx
neg    %rdx
neg    %rax
sbb    $0x0, %rdx
retq

Reply via email to