summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c
blob: b08c420cd86b039faf2c10aa40e2f46d37034c2f (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
/* { dg-do compile } */
/* { dg-options "-O3 -fdump-ipa-cp-details" } */

#define N 4

typedef int (* const A[N])(int);

typedef struct S
{
  int add_offset;
  A a;
} S;

extern const S *gs, *hs;

static int  __attribute__((noinline))
foo (const S f, int x)
{
  gs = &f;
  x = f.a[2](x);
  x = f.a[2](x);
  x = f.a[2](x);
  return x;
}

static int  __attribute__((noinline))
bar (const S f, int x)
{
  hs = &f;
  return foo (f, x);
}

static int
zero (int x)
{
  return 0;
}

static int
addone (int x)
{
  return x + 1;
}

static int
sq (int x)
{
  return x * x;
}

static int
cube (int x)
{
  return x * x * x;
}

static const S s = {64, {zero, addone, sq, cube}};

int
h (int x)
{
  return bar (s, x);
}

/* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" { xfail { hppa*-*-* && { ! lp64 } } } } } */