1 /* PR tree-optimization/27285 */
2 /* PR tree-optimization/45122 */
3
4 /* { dg-do run } */
5 /* { dg-options "-O2" } */
6
7 extern void abort (void);
8
9 struct S { unsigned char a, b, c, d[16]; };
10
11 void __attribute__ ((noinline))
foo(struct S * x,struct S * y)12 foo (struct S *x, struct S *y)
13 {
14 int a, b;
15 unsigned char c, *d, *e;
16
17 b = x->b;
18 d = x->d;
19 e = y->d;
20 a = 0;
21 while (b)
22 {
23 if (b >= 8)
24 {
25 c = 0xff;
26 b -= 8;
27 }
28 else
29 {
30 c = 0xff << (8 - b);
31 b = 0;
32 }
33
34 e[a] = d[a] & c;
35 a++;
36 }
37 }
38
39 int
main(void)40 main (void)
41 {
42 struct S x = { 0, 25, 0, { 0xaa, 0xbb, 0xcc, 0xdd }};
43 struct S y = { 0, 0, 0, { 0 }};
44
45 foo (&x, &y);
46 if (x.d[0] != y.d[0] || x.d[1] != y.d[1]
47 || x.d[2] != y.d[2] || (x.d[3] & 0x80) != y.d[3])
48 abort ();
49 return 0;
50 }
51