[LLVMbugs] [Bug 18224] New: strnstr is compiled MUCH less efficiently than with gcc 4.9 (at least on x86-64)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Dec 12 02:28:21 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=18224
Bug ID: 18224
Summary: strnstr is compiled MUCH less efficiently than with
gcc 4.9 (at least on x86-64)
Product: tools
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: llvm-gcc
Assignee: unassignedbugs at nondot.org
Reporter: roberto.avanzi at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11713
--> http://llvm.org/bugs/attachment.cgi?id=11713&action=edit
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
http://hpc.sourceforge.net), 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
http://computer-programming-forum.com/47-c-language/73a6072fc82f6cd9.htm
Roberto
--
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/20131212/321b677d/attachment.html>
More information about the llvm-bugs
mailing list