[llvm-bugs] [Bug 38092] New: Missed elimination of moves
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jul 8 06:44:55 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38092
Bug ID: 38092
Summary: Missed elimination of moves
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: llvm-bugs at lists.llvm.org
Hello,
Code:
struct replace_info {
int n;
char *text;
};
static int compare(const void *a, const void *b) {
struct replace_info *x = (struct replace_info *) a;
struct replace_info *y = (struct replace_info *) b;
return x->n - y->n;
}
int main(void) {
struct replace_info info[3] = {
{5, "Aaaa"},
{7, "Bbbb"},
{3, "Cccc"}
};
qsort(info, 3, sizeof(struct replace_info), compare);
}
Clang trunk (-O3):
main:
sub rsp, 56
xorps xmm0, xmm0 // *****
movaps xmmword ptr [rsp], xmm0 // *****
movaps xmmword ptr [rsp + 16], xmm0 // *****
movaps xmmword ptr [rsp + 32], xmm0 // *****
mov dword ptr [rsp], 5
mov qword ptr [rsp + 8], offset .L.str
mov dword ptr [rsp + 16], 7
mov qword ptr [rsp + 24], offset .L.str.1
mov dword ptr [rsp + 32], 3
mov qword ptr [rsp + 40], offset .L.str.2
mov rdi, rsp
mov esi, 3
mov edx, 16
mov ecx, offset compare
call qsort
xor eax, eax
add rsp, 56
ret
I think lines marked with "*****" are useless and GCC confirms it (does not
generate them).
GCC:
main:
sub rsp, 56
mov ecx, OFFSET FLAT:compare
mov edx, 16
mov esi, 3
mov rdi, rsp
mov DWORD PTR [rsp], 5
mov QWORD PTR [rsp+8], OFFSET FLAT:.LC0
mov DWORD PTR [rsp+16], 7
mov QWORD PTR [rsp+24], OFFSET FLAT:.LC1
mov DWORD PTR [rsp+32], 3
mov QWORD PTR [rsp+40], OFFSET FLAT:.LC2
call qsort
xor eax, eax
add rsp, 56
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/20180708/e7d4a790/attachment.html>
More information about the llvm-bugs
mailing list