New tests for memcpy/memset/strlen/strcmp/strncmp

Joseph S. Myers jsm28@cam.ac.uk
Sat Mar 9 14:53:00 GMT 2002


On Sat, 9 Mar 2002, Michael Meissner wrote:

> I was optimizing the string functions in newlib to speed up some
> common cases on the MIPS, and wrote the following tests to make sure
> that all combnations likely to be optimized of alignments and lengths
> are done.  I added this to the torture test suite.
> 
> 2002-03-09  Michael Meissner  <meissner@redhat.com>
> 
> 	* gcc.c-torture/execute/memcpy-2.c: New test.
> 	* gcc.c-torture/execute/memset-1.c: New test.
> 	* gcc.c-torture/execute/strlen-1.c: New test.
> 	* gcc.c-torture/execute/strcmp-1.c: New test.
> 	* gcc.c-torture/execute/strncmp-1.c: New test.

glibc also has its own tests for string functions.  It might make sense to 
try to have a common collection of tests for corner cases (which include 
not just alignments and lengths, but also e.g. strings at the end of a 
page, the next page being unmapped, to test that functions in such cases 
don't look further ahead in memory than the standard says they can).

Such tests would be used then in several configurations, over several 
optimisation options:

* To test GCC's built-in functions, with the built-in functions enabled,
and with the string functions explicitly declared rather than including
<string.h> (since <string.h> may have its own macro definitions).  This is
the only case of relevance to GCC.

* To test external versions in a library, with GCC's built-in functions 
enabled (possibly falling back to external ones).

* To test optimised versions in headers (whether macros or inlines,
whether using inline assembler or not).

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list