OSDN Git Service

PR rtl-optimization/52139
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tree-ssa / pr45122.c
1 /* PR tree-optimization/27285 */
2 /* PR tree-optimization/45122 */
3
4 /* { dg-do run } */
5 /* { dg-options "-O2 -funsafe-loop-optimizations" } */
6
7 extern void abort (void);
8
9 struct S { unsigned char a, b, c, d[16]; };
10
11 void __attribute__ ((noinline))
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
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 }