https://bugs.llvm.org/show_bug.cgi?id=43146
Bug ID: 43146
Summary: Compiler fails to optimize big endian load since clang
8.0
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: mv...@google.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
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 https://gcc.godbolt.org/z/YklsAm
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
https://gcc.godbolt.org/z/7rfh9J
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?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs