[llvm-bugs] [Bug 32086] New: Multiple moves compiled inefficiently
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Tue Feb 28 02:03:37 PST 2017
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=32086
            Bug ID: 32086
           Summary: Multiple moves compiled inefficiently
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: drraph at gmail.com
                CC: llvm-bugs at lists.llvm.org
Consider:
double a[4], b[4], c[4];
void foo ()
{
  a[0] = c[0];
  a[1] = c[1];
  a[2] = c[0];
  a[3] = c[1];
  b[0] = c[2];
  b[1] = c[3];
  b[2] = c[2];
  b[3] = c[3];
}
clang compiles this with -O3 to:
foo:                                    # @foo
        mov     rax, qword ptr [rip + c]
        mov     qword ptr [rip + a], rax
        mov     rcx, qword ptr [rip + c+8]
        mov     qword ptr [rip + a+8], rcx
        mov     qword ptr [rip + a+16], rax
        mov     qword ptr [rip + a+24], rcx
        mov     rax, qword ptr [rip + c+16]
        mov     qword ptr [rip + b], rax
        mov     rcx, qword ptr [rip + c+24]
        mov     qword ptr [rip + b+8], rcx
        mov     qword ptr [rip + b+16], rax
        mov     qword ptr [rip + b+24], rcx
        ret
gcc on the other hand gives the more efficient:
foo:
        movapd  xmm1, XMMWORD PTR c[rip]
        movapd  xmm0, XMMWORD PTR c[rip+16]
        movaps  XMMWORD PTR a[rip], xmm1
        movaps  XMMWORD PTR a[rip+16], xmm1
        movaps  XMMWORD PTR b[rip], xmm0
        movaps  XMMWORD PTR b[rip+16], xmm0
        ret
-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170228/9fae02ba/attachment.html>
    
    
More information about the llvm-bugs
mailing list