Bug 51838 - Inefficient add of 128 bit quantity represented as 64 bit tuple to 128 bit integer.
Inefficient add of 128 bit quantity represented as 64 bit tuple to 128 bit in...
Status: UNCONFIRMED
Product: gcc
Classification: Unclassified
Component: middle-end
4.7.0
: P3 enhancement
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-12 19:29 UTC by Steven Fuerst
Modified: 2012-01-12 20:10 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:29:40 UTC
void foo(__uint128_t *x, unsigned long long y, unsigned long long z)
{
	*x += y + ((__uint128_t) z << 64);
}

Compiles into:

mov    %rdx,%r8
mov    %rsi,%rax
xor    %edx,%edx
add    (%rdi),%rax
mov    %rdi,%rcx
adc    0x8(%rdi),%rdx
xor    %esi,%esi
add    %rsi,%rax
adc    %r8,%rdx
mov    %rax,(%rcx)
mov    %rdx,0x8(%rcx)
retq 

The above can be optimized into:

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