File: fold-bcopy.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (54 lines) | stat: -rw-r--r-- 1,550 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* PR tree-optimization/80933 - redundant bzero/bcopy calls not eliminated
   { dg-do compile }
   { dg-options "-O1 -Wall -fdump-tree-lower" } */

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" "lower" } }
  { dg-final { scan-tree-dump-times "memcmp|memmove|memset" 3 "lower" } }

  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 "lower" } }  */