<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Performance disparty between g++ and clang++ for recursive template execution"
   href="https://llvm.org/bugs/show_bug.cgi?id=26866">26866</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Performance disparty between g++ and clang++ for recursive template execution
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>wolfgang.brehm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15998" name="attach_15998" title="cpp source code to calculate floor of log2 using tail call recursion">attachment 15998</a> <a href="attachment.cgi?id=15998&action=edit" title="cpp source code to calculate floor of log2 using tail call recursion">[details]</a></span>
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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>