http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50339
Bug #: 50339 Summary: suboptimal register allocation for abs(__int128_t) Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: rtl-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: wouter.vermae...@scarlet.be This function: __int128_t abs128(__int128_t a) { return (a >= 0) ? a : -a; } Currently generates the following code (with -O3): (linux x86_64, g++-4.7.0, SVN revision 178692) 49 89 f9 mov %rdi,%r9 48 89 f7 mov %rsi,%rdi 49 89 f2 mov %rsi,%r10 48 c1 ff 3f sar $0x3f,%rdi 48 89 f8 mov %rdi,%rax 48 89 fa mov %rdi,%rdx 4c 31 c8 xor %r9,%rax 4c 31 d2 xor %r10,%rdx 48 29 f8 sub %rdi,%rax 48 19 fa sbb %rdi,%rdx c3 retq But the following has 2 'mov' instructions less: 48 89 f8 mov %rdi,%rax 48 89 f2 mov %rsi,%rdx 48 89 d1 mov %rdx,%rcx 48 c1 f9 3f sar $0x3f,%rcx 48 31 c8 xor %rcx,%rax 48 31 ca xor %rcx,%rdx 48 29 c8 sub %rcx,%rax 48 19 ca sbb %rcx,%rdx c3 retq