OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / compile / pr46248.c
1 /* PR rtl-optimization/46248 */
2
3 struct S
4 {
5   int s;
6 };
7
8 void
9 foo (unsigned char *x, int y, struct S *z)
10 {
11   const int l1 = y;
12   const int l2 = y + l1;
13   const int l3 = y + l2;
14   const int l4 = y + l3;
15   const int l5 = y + l4;
16   const int l6 = y + l5;
17   const int l7 = y + l6;
18   int i;
19   for (i = 0; i < 8; i++)
20     {
21       int a = x[l3] - x[l4];
22       int b = x[l4] - x[l5];
23       int c = x[l5] - x[l6];
24       int d = (b >= 0 ? b : -b) - (((a >= 0 ? a : -a) + (c >= 0 ? c : -c)) >> 1);
25       if (d < z->s * 2)
26         {
27           int v = d * (-b > 0 ? 1 : -1);
28           x[l2] += v >> 3;
29           x[l7] -= v >> 3;
30         }
31     }
32 }