summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/store_merging_6.c
blob: 314829da6d3c1d1e3f78cbec13f41927f4018ed8 (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
/* { dg-do run } */
/* { dg-require-effective-target store_merge } */
/* { dg-options "-O2 -fdump-tree-store-merging" } */

/* Check that we can widen accesses to bitfields.  */

struct bar {
  int a : 3;
  unsigned char b : 4;
  unsigned char c : 1;
  char d;
  char e;
  char f;
  char g;
};

__attribute__ ((noinline)) void
foozero (struct bar *p)
{
  p->b = 0;
  p->a = 0;
  p->c = 0;
  p->d = 0;
  p->e = 0;
  p->f = 0;
  p->g = 0;
}

__attribute__ ((noinline)) void
foo1 (struct bar *p)
{
  p->b = 3;
  p->a = 2;
  p->c = 1;
  p->d = 4;
  p->e = 5;
}

int
main (void)
{
  struct bar p;
  foozero (&p);
  foo1 (&p);
  if (p.a != 2 || p.b != 3 || p.c != 1 || p.d != 4 || p.e != 5
      || p.f != 0 || p.g != 0)
    __builtin_abort ();

  return 0;
}


/* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */