summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr78408-1.c
blob: 94e2090b374faa2c00c46afb17ca0f2e7a0f7abc (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* PR c/78408 */
/* { dg-do compile { target size32plus } } */
/* { dg-options "-O2 -fdump-tree-fab1-details" } */
/* { dg-final { scan-tree-dump-times "after previous" 17 "fab1" } } */

struct S { char a[32]; };
struct T { char a[65536]; };
void bar (int, struct S *, struct S *, struct T *, struct T *);
void baz (char *, char *);

void
f1 (void)
{
  struct S a, b;
  struct T c, d;
  a = b = (struct S) {};
  c = d = (struct T) {};
  bar (1, &a, &b, &c, &d);
}

void
f2 (void)
{
  struct S a, b;
  struct T c, d;
  b = (struct S) {};
  a = b;
  d = (struct T) {};
  c = d;
  bar (2, &a, &b, &c, &d);
}

void
f3 (void)
{
  struct S a, b;
  struct T c, d;
  __builtin_memset (&b, 0, sizeof (b));
  a = b;
  __builtin_memset (&d, 0, sizeof (d));
  c = d;
  bar (3, &a, &b, &c, &d);
}


void
f4 (void)
{
  struct S a, b;
  struct T c, d;
  b = (struct S) {};
  __builtin_memcpy (&a, &b, sizeof (b));
  d = (struct T) {};
  __builtin_memcpy (&c, &d, sizeof (d));
  bar (4, &a, &b, &c, &d);
}

void
f5 (void)
{
  struct S a, b;
  struct T c, d;
  __builtin_memset (&b, 0, sizeof (b));
  __builtin_memcpy (&a, &b, sizeof (b));
  __builtin_memset (&d, 0, sizeof (d));
  __builtin_memcpy (&c, &d, sizeof (d));
  bar (5, &a, &b, &c, &d);
}

void
f6 (void)
{
  struct S a, b, e, g;
  struct T c, d, f, h;
  g = e = a = b = (struct S) {};
  h = f = c = d = (struct T) {};
  bar (6, &a, &b, &c, &d);
  bar (6, &e, &g, &f, &h);
}

void
f7 (void)
{
  char a[64], b[64];
  __builtin_memset (a + 13, 2, 27);
  __builtin_memcpy (b + 4, a + 17, 23);
  baz (a, b);
}