<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Missed elimination of moves"
href="https://bugs.llvm.org/show_bug.cgi?id=38092">38092</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed elimination of moves
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>