<html>
    <head>
      <base href="http://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 --- - strnstr is compiled MUCH less efficiently than with gcc 4.9 (at least on x86-64)"
   href="http://llvm.org/bugs/show_bug.cgi?id=18224">18224</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>strnstr is compiled MUCH less efficiently than with gcc 4.9 (at least on x86-64)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>llvm-gcc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>roberto.avanzi@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=11713" name="attach_11713" title="This is the source code for a benchmark suite for various versions of the strstr library routine">attachment 11713</a> <a href="attachment.cgi?id=11713&action=edit" title="This is the source code for a benchmark suite for various versions of the strstr library routine">[details]</a></span>
This is the source code for a benchmark suite for various versions of the
strstr library routine

If i compile the attached file "strstrtest.c" with gcc 4.9 
(this is "gcc (GCC) 4.9.0 20130929 (experimental)" downloaded from
<a href="http://hpc.sourceforge.net">http://hpc.sourceforge.net</a>), with command

/usr/local/bin/gcc -O3 strstrtest.c -o strstrtest-gcc

and run it (I have a file containing the complete works of shakespeare)
the benchmark result is

mocenigo$ ./strstrtest-gcc 10 < shakespeare.txt
loopcount: 10
strstr :         0.4972 seconds
strstr0:         0.4998 seconds
strstr1:         0.5735 seconds
strstr2:         0.2761 seconds

If I compile with clang ("Apple LLVM version 5.0 (clang-500.2.79) (based on
LLVM 3.3svn"), using command
clang -O3 strstrtest.c -o strstrtest-clang
the results are

ravanzi-mac:strstr mocenigo$ ./strstrtest-clang  10 < shakespeare.txt
loopcount: 10
strstr :         0.4938 seconds
strstr0:         0.4302 seconds
strstr1:         0.4518 seconds
strstr2:         0.4129 seconds

For some reason the gcc compiled version of strstr2 (which is the one that
comes from the FreeBSD sources, it is the one used also by Apple in OS X, and
is probably the fastest version around) is MUCH faster, whereas the other
versions are comparable or slower. There may be some trick used by gcc here
that vastly improves the performance of this particular version of strstr, or
some optimization that does not kick in in clang.

With other, larger or smaller test text files the result is essentially the
same: the version compiled with gcc takes abut 2/3 of the time took by the
clang compiled version.

I am trying to set up a hexagon environment to verify if this happens also
there.

NB: the strstr.c file has been obtained from
<a href="http://computer-programming-forum.com/47-c-language/73a6072fc82f6cd9.htm">http://computer-programming-forum.com/47-c-language/73a6072fc82f6cd9.htm</a> 

 Roberto</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>