1 /* PR tree-optimization/80933 - redundant bzero/bcopy calls not eliminated
3 { dg-options "-O0 -Wall -fdump-tree-gimple" } */
5 void f0 (void *dst
, const void *src
, unsigned n
)
7 /* Bcopy(src, dst, ...) corresponds to memmove(dst, src, ...),
8 with the first two arguments transposed, not memcpy. */
9 __builtin_bcopy (src
, dst
, n
);
12 void f1 (void *p
, const void *q
, unsigned n
)
14 /* A call with zero size should be eliminated. */
15 __builtin_bcopy (q
, p
, 0);
18 int f2 (const void *p
, const void *q
, unsigned n
)
20 return __builtin_bcmp (p
, q
, n
);
23 int f3 (const void *p
, const void *q
)
25 /* A call with zero size should be folded into 0. */
26 return __builtin_bcmp (p
, q
, 0);
29 int f4 (const void *p
, unsigned n
)
31 /* A call with the same argument should also be folded into 0. */
32 return __builtin_bcmp (p
, p
, n
);
35 void f5 (void *p
, unsigned n
)
37 __builtin_bzero (p
, n
);
42 /* A call with zero size should be eliminated. */
43 __builtin_bzero (p
, 0);
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" } }
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" } } */