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