PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / reassoc-28.c
blob2e9998601485a986e14c94250c200cfee235a851
1 /* { dg-do run} */
2 /* { dg-options "-O2" } */
4 #define LENGTH 4
5 void abort (void);
6 unsigned
7 __attribute__ ((noinline)) foo (unsigned char *buf, int n)
9 unsigned sum = 0, i = 0;
10 do {
11 sum +=(buf)[n-1];
12 /* Split the BB to test statements are correctly moved to
13 satisfy dependences. */
14 if (n > LENGTH)
15 i++;
16 sum += buf[n-2];
17 sum += buf[n-3];
18 sum += buf[n-4];
19 n = n-4;
20 } while (n > 0);
22 return sum + i;
25 unsigned char a[] = {1, 1, 1, 1};
27 int main() {
28 int sum = foo (a, LENGTH);
29 if (sum != 4)
30 abort ();
31 return 0;