https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66012
Bug ID: 66012
Summary: Sub-optimal 64bit load is generated instead of
zero-extension
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
This testcase:
--cut here--
long l[4];
long long test (void)
{
return (l[0] & (long long) 0xffffffff)
| ((l[1] & (long long) 0xffffffff) << 32);
}
--cut here--
generates non-optimal 64bit load:
movl l(%rip), %edx
>> movq l+8(%rip), %rax
salq $32, %rax
orq %rdx, %rax
ret
The .optimized dump is already missing masking that would generate
zero-extension on x86_64:
test ()
{
long int _2;
long long int _3;
long int _4;
long long int _5;
long long int _6;
<bb 2>:
_2 = l[0];
_3 = _2 & 4294967295;
_4 = l[1];
_5 = _4 << 32;
_6 = _3 | _5;
return _6;
}