<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 - Compiler fails to optimize big endian load since clang 8.0"
href="https://bugs.llvm.org/show_bug.cgi?id=43146">43146</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Compiler fails to optimize big endian load since clang 8.0
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mvels@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The compiler fails to recognize a BigEndian load opportunity since clang 7
Consider:
struct BESize {
unsigned char c1;
unsigned char c2;
unsigned char c3;
unsigned char c4;
unsigned char c5;
unsigned char c6;
unsigned char c7;
unsigned char c8;
uint64_t Load() const {
return
(static_cast<uint64_t>(c1) << 56) |
(static_cast<uint64_t>(c2) << 48) |
(static_cast<uint64_t>(c3) << 40) |
(static_cast<uint64_t>(c4) << 32) |
(static_cast<uint64_t>(c5) << 24) |
(static_cast<uint64_t>(c6) << 16) |
(static_cast<uint64_t>(c7) << 8) |
static_cast<uint64_t>(c8);
}
};
Compiling this with clang 7.0 -O3 -march=haswell, it creates proper movbe code:
As per <a href="https://gcc.godbolt.org/z/YklsAm">https://gcc.godbolt.org/z/YklsAm</a>
uint64_t load_be2(const BESize* p) {
return p->Load();
}
-->
load_be2(BESize const*): # @load_be2(BESize const*)
movbe rax, qword ptr [rdi]
ret
Starting with clang 8.0, it generates a bunch of avx code, see
<a href="https://gcc.godbolt.org/z/7rfh9J">https://gcc.godbolt.org/z/7rfh9J</a>
clang 8.0 still recognizes it is a Big Endian load, as running without
-march=haswell, it creates:
load_be2(BESize const*): # @load_be2(BESize const*)
mov rax, qword ptr [rdi]
bswap rax
ret
Is this by design? I would guess the movbe is desirable over the AVX code?</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>