Commit 67bf5d01 by Jakub Jelinek Committed by Jakub Jelinek

string-4.c (main_test): Allow some mempcpy/stpcpy calls not to be optimized into something else.

	* gcc.c-torture/execute/builtins/string-4.c (main_test): Allow some
	mempcpy/stpcpy calls not to be optimized into something else.
	* gcc.c-torture/execute/string-opt-3.c: Moved to...
	* gcc.c-torture/execute/builtins/string-7.c: ...here.
	* gcc.c-torture/execute/builtins/string-7-lib.c: New.

From-SVN: r67538
parent f0718851
2003-06-06 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/builtins/string-4.c (main_test): Allow some
mempcpy/stpcpy calls not to be optimized into something else.
* gcc.c-torture/execute/string-opt-3.c: Moved to...
* gcc.c-torture/execute/builtins/string-7.c: ...here.
* gcc.c-torture/execute/builtins/string-7-lib.c: New.
2003-06-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/format/asm_fprintf-1.c: New test.
......
......@@ -12,6 +12,7 @@ extern size_t strlen(const char *);
extern void *memcpy (void *, const void *, size_t);
extern void *mempcpy (void *, const void *, size_t);
extern int memcmp (const void *, const void *, size_t);
extern int inside_main;
const char s1[] = "123";
char p[32] = "";
......@@ -24,6 +25,13 @@ main_test (void)
{
int i;
#if !defined __i386__ && !defined __x86_64__
/* The functions below might not be optimized into direct stores on all
arches. It depends on how many instructions would be generated and
what limits the architecture chooses in STORE_BY_PIECES_P. */
inside_main = 0;
#endif
if (stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
abort ();
if (stpcpy (p + 16, "vwxyz" + 1) != p + 16 + 4 || memcmp (p + 16, "wxyz", 5))
......@@ -63,7 +71,9 @@ main_test (void)
abort ();
/* If the result of stpcpy/mempcpy is ignored, gcc should use
strcpy/memcpy. */
strcpy/memcpy. This should be optimized always, so set inside_main
again. */
inside_main = 1;
stpcpy (p + 3, s2);
if (memcmp (p, "ABCdefg", 8))
abort ();
......
#include "lib/stpcpy.c"
#include "lib/mempcpy.c"
......@@ -9,6 +9,7 @@ typedef __SIZE_TYPE__ size_t;
extern void *mempcpy (void *, const void *, size_t);
extern int memcmp (const void *, const void *, size_t);
extern char *stpcpy (char *, const char *);
extern int inside_main;
long buf1[64];
char *buf2 = (char *) (buf1 + 32);
......@@ -157,10 +158,12 @@ test (long *buf3, char *buf4, char *buf6, int n)
return 0;
}
int
main ()
void
main_test (void)
{
/* All these tests are allowed to call mempcpy/stpcpy. */
inside_main = 0;
__builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
__builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
return test (buf1, buf2, "rstuvwxyz", 0);
test (buf1, buf2, "rstuvwxyz", 0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment