[llvm-bugs] [Bug 44895] New: Use ROL to swap scalars
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 13 06:18:51 PST 2020
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: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
#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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200213/671507b7/attachment.html>
More information about the llvm-bugs
mailing list