[llvm-bugs] [Bug 26866] New: Performance disparty between g++ and clang++ for recursive template execution

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 7 05:27:45 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26866

            Bug ID: 26866
           Summary: Performance disparty between g++ and clang++ for
                    recursive template execution
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: wolfgang.brehm at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 15998
  --> https://llvm.org/bugs/attachment.cgi?id=15998&action=edit
cpp source code to calculate floor of log2 using tail call recursion

This probably has to do with non guaranteed tail call recursion optimization.
I think my recursieve templated floor_log2 implementation could be a good test
case to optimize clang++ as the g++ compiled executable is about 3 times
faster.
The relevant code:
[...]
constexpr floor_log2(const T& x,const T& lower,const T& upper){
  return (upper-lower==T(1))?lower:(x&(T(0)-T(1)<<((upper+lower)/2))?
         floor_log2(x,(upper+lower)/2,upper):
         floor_log2(x,lower,(upper+lower)/2));
}
[...]
see attachment for minimal working example.

-- 
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/20160307/870aa5ed/attachment-0001.html>


More information about the llvm-bugs mailing list