annotate gcc/testsuite/gcc.dg/fold-bcopy.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* PR tree-optimization/80933 - redundant bzero/bcopy calls not eliminated
kono
parents:
diff changeset
2 { dg-do compile }
kono
parents:
diff changeset
3 { dg-options "-O0 -Wall -fdump-tree-gimple" } */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 void f0 (void *dst, const void *src, unsigned n)
kono
parents:
diff changeset
6 {
kono
parents:
diff changeset
7 /* Bcopy(src, dst, ...) corresponds to memmove(dst, src, ...),
kono
parents:
diff changeset
8 with the first two arguments transposed, not memcpy. */
kono
parents:
diff changeset
9 __builtin_bcopy (src, dst, n);
kono
parents:
diff changeset
10 }
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 void f1 (void *p, const void *q, unsigned n)
kono
parents:
diff changeset
13 {
kono
parents:
diff changeset
14 /* A call with zero size should be eliminated. */
kono
parents:
diff changeset
15 __builtin_bcopy (q, p, 0);
kono
parents:
diff changeset
16 }
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 int f2 (const void *p, const void *q, unsigned n)
kono
parents:
diff changeset
19 {
kono
parents:
diff changeset
20 return __builtin_bcmp (p, q, n);
kono
parents:
diff changeset
21 }
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 int f3 (const void *p, const void *q)
kono
parents:
diff changeset
24 {
kono
parents:
diff changeset
25 /* A call with zero size should be folded into 0. */
kono
parents:
diff changeset
26 return __builtin_bcmp (p, q, 0);
kono
parents:
diff changeset
27 }
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 int f4 (const void *p, unsigned n)
kono
parents:
diff changeset
30 {
kono
parents:
diff changeset
31 /* A call with the same argument should also be folded into 0. */
kono
parents:
diff changeset
32 return __builtin_bcmp (p, p, n);
kono
parents:
diff changeset
33 }
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 void f5 (void *p, unsigned n)
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 __builtin_bzero (p, n);
kono
parents:
diff changeset
38 }
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 void f6 (void *p)
kono
parents:
diff changeset
41 {
kono
parents:
diff changeset
42 /* A call with zero size should be eliminated. */
kono
parents:
diff changeset
43 __builtin_bzero (p, 0);
kono
parents:
diff changeset
44 }
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 /* Verify that calls to bcmp, bcopy, and bzero have all been removed
kono
parents:
diff changeset
47 and one of each replaced with memcmp, memmove, and memset, respectively.
kono
parents:
diff changeset
48 The remaining three should be eliminated.
kono
parents:
diff changeset
49 { dg-final { scan-tree-dump-not "bcmp|bcopy|bzero" "gimple" } }
kono
parents:
diff changeset
50 { dg-final { scan-tree-dump-times "memcmp|memmove|memset" 3 "gimple" } }
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 Verify that the bcopy to memmove transformation correctly transposed
kono
parents:
diff changeset
53 the source and destination pointer arguments.
kono
parents:
diff changeset
54 { dg-final { scan-tree-dump-times "memmove \\(dst, src" 1 "gimple" } } */