1/* { dg-do compile } */
2/* { dg-options "-O2 -fno-ipa-cp-alignment -fno-early-inlining -fdump-ipa-cp -fdump-tree-optimized" } */
3
4#include <stdint.h>
5
6extern int fail_the_test(void *);
7extern int pass_the_test(void *);
8extern int diversion (void *);
9
10struct somestruct
11{
12  void *whee;
13  void *oops;
14};
15
16struct container
17{
18  struct somestruct first;
19  struct somestruct buf[32];
20};
21
22static int __attribute__((noinline))
23foo (void *p)
24{
25  uintptr_t a = (uintptr_t) p;
26
27  if (a % 4)
28    return fail_the_test (p);
29  else
30    return pass_the_test (p);
31}
32
33int
34bar (void)
35{
36  struct container c;
37  return foo (c.buf);
38}
39
40
41static int
42through (struct somestruct *p)
43{
44  diversion (p);
45  return foo (&p[16]);
46}
47
48int
49bar2 (void)
50{
51  struct container c;
52  through (c.buf);
53}
54
55/* { dg-final { scan-ipa-dump-not "Adjusting alignment of param" "cp" } } */
56/* { dg-final { scan-tree-dump "fail_the_test" "optimized" } } */
57/* { dg-final { cleanup-ipa-dump "cp" } } */
58/* { dg-final { cleanup-tree-dump "optimized" } } */
59