https://bugs.llvm.org/show_bug.cgi?id=44895

            Bug ID: 44895
           Summary: Use ROL to swap scalars
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

#include <utility>


void swap (std::pair<int, int> &x)
  {
    int y[2], t;
    __builtin_memcpy (y, &x, sizeof x);
    t = y[0]; y[0] = y[1]; y[1] = t;
    __builtin_memcpy (&x, y, sizeof x);
  }

Clang -Oz/O3:
        movl    (%rdi), %eax
        movl    4(%rdi), %ecx
        movl    %ecx, (%rdi)
        movl    %eax, 4(%rdi)
        retq

GCC 9.2:
        rol     QWORD PTR [rdi], 32

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to