[Bug rtl-optimization/60473] New: optimization after shift sub-optimal

marmoo1024 at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Mar 9 13:52:00 GMT 2014


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

            Bug ID: 60473
           Summary: optimization after shift sub-optimal
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marmoo1024 at gmail dot com

Created attachment 32316
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32316&action=edit
source file with outputs, 3 versions with simple function using them

unsigned long long simple_rdtsc_64 () {
unsigned long long h,l;
asm volatile ("rdtsc": "=a" (l), "=d" (h));
return (l) | (h << 32);
}

Optimizes to:

rdtsc
salq    $32, %rdx
orq     %rax, %rdx
movq    %rdx, %rax
ret

with "return l+h*0x100000000LLU;" it optimizes better

rdtsc
salq    $32, %rdx
addq    %rdx, %rax
ret

This also seems to affects how the function is inlined (see file).



More information about the Gcc-bugs mailing list