[llvm-bugs] [Bug 27344] New: __builtin_expect(cond, 0) always produces CMOV under -O2
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Apr 13 14:51:56 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27344
Bug ID: 27344
Summary: __builtin_expect(cond, 0) always produces CMOV under
-O2
Product: clang
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: libclang
Assignee: unassignedclangbugs at nondot.org
Reporter: brian.armstrong.ece at gmail.com
CC: klimek at google.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 16215
--> https://llvm.org/bugs/attachment.cgi?id=16215&action=edit
Find minimum element of an array
I have an if statement with __builtin_expect where I expect the branch will be
taken very seldom. However, clang will always produce cmov instructions for
this branch. I suspect that branches will be faster for this particular case,
although I haven't been able to get clang to produce the branch version in
order to do the comparison.
Although I generally try to trust the compiler's judgment for these sorts of
matters, it would be nice to be able to compare the behavior for branches vs
cmov. In my particular program, I'm spending 25% of my CPU time on a pair of
cmovs similar to the snippet attached.
--
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/20160413/a3a67b20/attachment.html>
More information about the llvm-bugs
mailing list