]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
string-4.c (main_test): Allow some mempcpy/stpcpy calls not to be optimized into...
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Jun 2003 10:11:06 +0000 (12:11 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Jun 2003 10:11:06 +0000 (12:11 +0200)
* 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

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/builtins/string-4.c
gcc/testsuite/gcc.c-torture/execute/builtins/string-7-lib.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/builtins/string-7.c [moved from gcc/testsuite/gcc.c-torture/execute/string-opt-3.c with 96% similarity]

index 3494c609be85bf855ab7825dc7dd8f7522255e0d..4832f7312dc21468d85b2f48a621e0af2effc4f4 100644 (file)
@@ -1,3 +1,11 @@
+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.
index 0d0544e3de2e6b86c428a2c692be61e8d0fabc30..51819b1cfa96a7d487bcf18d6e15dde25ec16d85 100644 (file)
@@ -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 ();
diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/string-7-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/string-7-lib.c
new file mode 100644 (file)
index 0000000..3b69c3b
--- /dev/null
@@ -0,0 +1,2 @@
+#include "lib/stpcpy.c"
+#include "lib/mempcpy.c"
similarity index 96%
rename from gcc/testsuite/gcc.c-torture/execute/string-opt-3.c
rename to gcc/testsuite/gcc.c-torture/execute/builtins/string-7.c
index 71a41cdbf4ec8c7609d50419eb157d53f95c95f4..5eb1ac4af78d5b620e8c6692a9387bd16b7bb2fb 100644 (file)
@@ -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);
 }