summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipa-sra-13.c
blob: 4d4ed74cfd6ac40dd982912e4bc7f4a3b64fddc1 (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
/* { dg-do run } */
/* { dg-options "-O2 -fipa-sra -fdump-ipa-sra"  } */

/* Check of a by-reference structure split. */

struct S
{
  float red;
  void *blue;
  int green;
};

void __attribute__((noipa))
check (float r, int g, int g2)
{
  if (r < 7.39 || r > 7.41
      || g != 6 || g2 != 6)
    __builtin_abort ();
}

static void
__attribute__((noinline))
foo (struct S *s)
{
  check (s->red, s->green, s->green);
}

static void
__attribute__((noinline))
bar (struct S *s)
{
  foo (s);
}

int
main (int argc, char *argv[])
{
  struct S s;

  s.red = 7.4;
  s.green = 6;
  s.blue = &s;

  bar (&s);
  return 0;
}

/* { dg-final { scan-ipa-dump-times "Will split parameter" 2 "sra" } } */
/* { dg-final { scan-ipa-dump-times "component at byte offset" 4 "sra" } } */