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

             Bug #: 51839
           Summary: GCC not generating adc instruction for canonical
                    multi-precision add sequence
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: svfue...@gmail.com


The multi-precision add

void foo(unsigned long long *x, unsigned long long y, unsigned long long z)
{
    x[0] += y;
    x[1] += z + (x[0] < y);
}

compiles into:

mov    %rsi,%rax
add    (%rdi),%rax
add    0x8(%rdi),%rdx
cmp    %rax,%rsi
mov    %rax,(%rdi)
seta   %al
movzbl %al,%eax
add    %rax,%rdx
mov    %rdx,0x8(%rdi)
retq

Instead, gcc could use the adc instruction, yielding the wanted:

add    %rsi, (%rdi)
adc    %rdx, 8(%rdi)
retq

Reply via email to