Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/gcc.dg/fold-bcopy.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 1830386684a0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/gcc.dg/fold-bcopy.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,54 @@ +/* PR tree-optimization/80933 - redundant bzero/bcopy calls not eliminated + { dg-do compile } + { dg-options "-O0 -Wall -fdump-tree-gimple" } */ + +void f0 (void *dst, const void *src, unsigned n) +{ + /* Bcopy(src, dst, ...) corresponds to memmove(dst, src, ...), + with the first two arguments transposed, not memcpy. */ + __builtin_bcopy (src, dst, n); +} + +void f1 (void *p, const void *q, unsigned n) +{ + /* A call with zero size should be eliminated. */ + __builtin_bcopy (q, p, 0); +} + +int f2 (const void *p, const void *q, unsigned n) +{ + return __builtin_bcmp (p, q, n); +} + +int f3 (const void *p, const void *q) +{ + /* A call with zero size should be folded into 0. */ + return __builtin_bcmp (p, q, 0); +} + +int f4 (const void *p, unsigned n) +{ + /* A call with the same argument should also be folded into 0. */ + return __builtin_bcmp (p, p, n); +} + +void f5 (void *p, unsigned n) +{ + __builtin_bzero (p, n); +} + +void f6 (void *p) +{ + /* A call with zero size should be eliminated. */ + __builtin_bzero (p, 0); +} + +/* Verify that calls to bcmp, bcopy, and bzero have all been removed + and one of each replaced with memcmp, memmove, and memset, respectively. + The remaining three should be eliminated. + { dg-final { scan-tree-dump-not "bcmp|bcopy|bzero" "gimple" } } + { dg-final { scan-tree-dump-times "memcmp|memmove|memset" 3 "gimple" } } + + Verify that the bcopy to memmove transformation correctly transposed + the source and destination pointer arguments. + { dg-final { scan-tree-dump-times "memmove \\(dst, src" 1 "gimple" } } */