summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr58145-2.c
blob: d26c05bc283924e55977ba28496cd25a4fb95a84 (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
/* PR tree-optimization/58145 */
/* { dg-do compile { target { int32plus } } } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

struct S { unsigned int data : 32; };
struct T { unsigned int data; };
volatile struct S s2;

static inline void
f1 (int val)
{
  struct S s = { .data = val };
  *(volatile struct S *) 0x880000UL = s;
}

static inline void
f2 (int val)
{
  struct T t = { .data = val };
  *(volatile struct T *) 0x880000UL = t;
}

static inline void
f3 (int val)
{
  *(volatile unsigned int *) 0x880000UL = val;
}

static inline void
f4 (int val)
{
  struct S s = { .data = val };
  s2 = s;
}

void
f5 (void)
{
  int i;
  for (i = 0; i < 100; i++)
    f1 (0);
  for (i = 0; i < 100; i++)
    f2 (0);
  for (i = 0; i < 100; i++)
    f3 (0);
  for (i = 0; i < 100; i++)
    f4 (0);
}

/* { dg-final { scan-tree-dump-times " ={v} " 4 "optimized" } } */