]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/store_merging_32.c
1 /* PR tree-optimization/97053 */
3 /* { dg-options "-O2 -fno-tree-dse" } */
5 struct __attribute__((packed
, may_alias
)) S
{ long long s
; };
6 struct __attribute__((packed
, may_alias
)) T
{ short t
; };
8 __attribute__((noipa
)) void
9 test (char *p
, char *q
, int s
)
13 if (*(short __attribute__((may_alias
)) *) &p
[sizeof (short)]
14 != *(short __attribute__((may_alias
)) *) &q
[sizeof (short)]
15 || (((struct S
__attribute__((may_alias
)) *) &p
[1])->s
16 != ((struct S
__attribute__((may_alias
)) *) &q
[1])->s
)
17 || (*(short __attribute__((may_alias
)) *) &p
[2 * sizeof (short)]
18 != *(short __attribute__((may_alias
)) *) &q
[2 * sizeof (short)]))
23 if (*(short __attribute__((may_alias
)) *) &p
[sizeof (short)]
24 != *(short __attribute__((may_alias
)) *) &q
[sizeof (short)]
25 || (((struct S
__attribute__((may_alias
)) *) &p
[1])->s
26 != ((struct S
__attribute__((may_alias
)) *) &q
[1])->s
)
27 || (((struct T
__attribute__((may_alias
)) *) &p
[2 * sizeof (short) - 1])->t
28 != ((struct T
__attribute__((may_alias
)) *) &q
[2 * sizeof (short) - 1])->t
)
29 || p
[3 * sizeof (short) - 2] != q
[3 * sizeof (short) - 2])
34 __attribute__((noipa
)) void
35 foo (long long *p
, char *q
, char *r
, char *s
)
37 char a
[64] __attribute__((aligned (__alignof (short))));
38 *(short __attribute__((may_alias
)) *) &a
[sizeof (short)] = 1;
39 ((struct S
__attribute__((may_alias
)) *) &a
[1])->s
= p
[0];
40 *(short __attribute__((may_alias
)) *) &a
[2 * sizeof (short)] = 2;
41 *(short __attribute__((may_alias
)) *) &q
[sizeof (short)] = 1;
42 ((struct S
__attribute__((may_alias
)) *) &r
[1])->s
= p
[0];
43 *(short __attribute__((may_alias
)) *) &s
[2 * sizeof (short)] = 2;
47 __attribute__((noipa
)) void
48 bar (long long *p
, char *q
, char *r
, char *s
, char *t
)
50 char a
[64] __attribute__((aligned (__alignof (short))));
51 *(short __attribute__((may_alias
)) *) &a
[sizeof (short)] = 1;
52 ((struct S
__attribute__((may_alias
)) *) &a
[1])->s
= p
[0];
53 ((struct T
__attribute__((may_alias
)) *) &a
[2 * sizeof (short) - 1])->t
= 2;
54 a
[3 * sizeof (short) - 2] = 3;
55 *(short __attribute__((may_alias
)) *) &q
[sizeof (short)] = 1;
56 ((struct S
__attribute__((may_alias
)) *) &r
[1])->s
= p
[0];
57 ((struct T
__attribute__((may_alias
)) *) &s
[2 * sizeof (short) - 1])->t
= 2;
58 t
[3 * sizeof (short) - 2] = 3;
62 __attribute__((noipa
)) void
63 baz (long long *p
, char *q
, char *r
, char *s
)
65 char a
[64] __attribute__((aligned (__alignof (short))));
66 *(short __attribute__((may_alias
)) *) &a
[2 * sizeof (short)] = 2;
67 ((struct S
__attribute__((may_alias
)) *) &a
[1])->s
= p
[0];
68 *(short __attribute__((may_alias
)) *) &a
[sizeof (short)] = 1;
69 *(short __attribute__((may_alias
)) *) &q
[2 * sizeof (short)] = 2;
70 ((struct S
__attribute__((may_alias
)) *) &r
[1])->s
= p
[0];
71 *(short __attribute__((may_alias
)) *) &s
[sizeof (short)] = 1;
75 __attribute__((noipa
)) void
76 qux (long long *p
, char *q
, char *r
, char *s
, char *t
)
78 char a
[64] __attribute__((aligned (__alignof (short))));
79 *(short __attribute__((may_alias
)) *) &a
[2 * sizeof (short) - 1] = 2;
80 ((struct S
__attribute__((may_alias
)) *) &a
[1])->s
= p
[0];
81 a
[3 * sizeof (short) - 2] = 3;
82 *(short __attribute__((may_alias
)) *) &a
[sizeof (short)] = 1;
83 ((struct T
__attribute__((may_alias
)) *) &q
[2 * sizeof (short) - 1])->t
= 2;
84 ((struct S
__attribute__((may_alias
)) *) &r
[1])->s
= p
[0];
85 s
[3 * sizeof (short) - 2] = 3;
86 ((struct T
__attribute__((may_alias
)) *) &t
[sizeof (short)])->t
= 1;
90 __attribute__((noipa
)) void
91 corge (long long *p
, char *q
, char *r
, char *s
, short u
[3])
93 char a
[64] __attribute__((aligned (__alignof (short))));
94 *(short __attribute__((may_alias
)) *) &a
[2 * sizeof (short)] = u
[2];
95 ((struct S
__attribute__((may_alias
)) *) &a
[1])->s
= p
[0];
96 *(short __attribute__((may_alias
)) *) &a
[sizeof (short)] = u
[1];
97 *(short __attribute__((may_alias
)) *) &q
[2 * sizeof (short)] = u
[2];
98 ((struct S
__attribute__((may_alias
)) *) &r
[1])->s
= p
[0];
99 *(short __attribute__((may_alias
)) *) &s
[sizeof (short)] = u
[1];
103 __attribute__((noipa
)) void
104 garply (long long *p
, char *q
, char *r
, char *s
, short u
[3])
106 char a
[64] __attribute__((aligned (__alignof (short))));
107 *(short __attribute__((may_alias
)) *) &a
[sizeof (short)] = u
[1];
108 ((struct S
__attribute__((may_alias
)) *) &a
[1])->s
= p
[0];
109 *(short __attribute__((may_alias
)) *) &a
[2 * sizeof (short)] = u
[2];
110 *(short __attribute__((may_alias
)) *) &s
[sizeof (short)] = u
[1];
111 ((struct S
__attribute__((may_alias
)) *) &r
[1])->s
= p
[0];
112 *(short __attribute__((may_alias
)) *) &q
[2 * sizeof (short)] = u
[2];
119 char a
[64] __attribute__((aligned (__alignof (short))));
121 short u
[] = { 1, 2, 3 };
122 foo (&p
, &a
[0], &a
[0], &a
[0]);
123 bar (&p
, &a
[0], &a
[0], &a
[0], &a
[0]);
124 baz (&p
, &a
[0], &a
[0], &a
[0]);
125 qux (&p
, &a
[0], &a
[0], &a
[0], &a
[0]);
126 corge (&p
, &a
[0], &a
[0], &a
[0], u
);
127 garply (&p
, &a
[0], &a
[0], &a
[0], u
);