[llvm-bugs] [Bug 42358] New: Bad code generation for __builtin_clrsbl
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 21 12:52:38 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42358
Bug ID: 42358
Summary: Bad code generation for __builtin_clrsbl
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: gabravier at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
When compiling this code :
int clrsbl(unsigned long x)
{
return __builtin_clrsbl(x);
}
Clang generates really bad code on several backends (x64, x86, RISCV-32,
RISCV-64), such as (on x64)
mov eax, 64
add eax, -1
or (on RISCV-32)
addi a0, zero, 32
addi a0, a0, -1
This bug, however, is not present on certain backends such as WebAssembly or
PowerPC 64 (le and not le)
I looked at the emitted llvm code, and I think this is probably an optimization
problem related specifically to @llvm.ctlz. It looks like it's expanding ctlz
after the passes that would eliminate the bad code.
Link to see examples of this across backends : https://godbolt.org/z/pbBKgD
I filed this as an x86 backend bug because I do not know how to file a bug for
several backends at the same time
--
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/20190621/83223b7f/attachment.html>
More information about the llvm-bugs
mailing list