PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtins / memmove-2.c
blob3afe3431338c190a1931b5eef4c99d492e502420
1 /* Copyright (C) 2004 Free Software Foundation.
3 Check builtin memmove and bcopy optimization when length is 1.
5 Written by Jakub Jelinek, 9/14/2004. */
7 extern void abort (void);
8 typedef __SIZE_TYPE__ size_t;
9 extern void *memmove (void *, const void *, size_t);
10 extern void bcopy (const void *, void *, size_t);
11 extern int memcmp (const void *, const void *, size_t);
13 char p[32] = "abcdefg";
14 char *q = p + 4;
16 void
17 main_test (void)
19 /* memmove with length 1 can be optimized into memcpy if it can be
20 expanded inline. */
21 if (memmove (p + 2, p + 3, 1) != p + 2 || memcmp (p, "abddefg", 8))
22 abort ();
23 if (memmove (p + 1, p + 1, 1) != p + 1 || memcmp (p, "abddefg", 8))
24 abort ();
25 if (memmove (q, p + 4, 1) != p + 4 || memcmp (p, "abddefg", 8))
26 abort ();
27 bcopy (p + 5, p + 6, 1);
28 if (memcmp (p, "abddeff", 8))
29 abort ();
30 bcopy (p + 1, p + 1, 1);
31 if (memcmp (p, "abddeff", 8))
32 abort ();
33 bcopy (q, p + 4, 1);
34 if (memcmp (p, "abddeff", 8))
35 abort ();