Bug 51839 - GCC not generating adc instruction for canonical multi-precision add sequence
Summary: GCC not generating adc instruction for canonical multi-precision add sequence
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-12 19:35 UTC by Steven Fuerst
Modified: 2012-01-12 20:09 UTC (History)
0 users

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Fuerst 2012-01-12 19:35:38 UTC
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