https://bugs.llvm.org/show_bug.cgi?id=33869
Ori Livneh <a...@google.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |---
Status|RESOLVED |REOPENED
--- Comment #24 from Ori Livneh <a...@google.com> ---
As far as I can tell, clang still does not break the dependency in the
reproduction case I attached in comment 14. Minimally:
#include <cstdint>
#include <x86intrin.h>
__attribute__((noinline))
int msb(uint64_t n) {
return 63 ^ __builtin_clzll(n);
}
clang version 7.0.0 (trunk 327823), -O2 -march=haswell:
lzcnt rax, rdi
xor eax, 63
ret
g++ 8.0.1 20180319, -O2 -march=haswell:
xor eax, eax
lzcnt rax, rdi
xor eax, 63
ret
https://godbolt.org/g/JC57Ri
The failure to break the dependency chain causes a measurable degradation in
performance when the function is called in a loop. I tested on one Haswell
machine and one Broadwell machine.
Worse, clang is shooting itself in the foot. If you compile the same code but
target an older microarchitecture w/no lzcnt (-march=core-i7 for example),
clang emits a bsr instruction instead, which doesn't appear to suffer from this
false dependency issue.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs