PR tree-optimization/33562
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ivopts-lower_base.c
blob1dca97d0ec66487c9aa9cf07efa3a785a7e3e0ad
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-ivopts-details" } */
3 #include <string.h>
4 #include <stdlib.h>
6 #define MAX_NUM (256)
8 void
9 sort_pointers (size_t n, void **pointers, void **work)
11 typedef unsigned char digit_t;
12 unsigned int count[MAX_NUM];
13 int big_endian_p;
14 size_t i;
15 size_t j;
17 if ((sizeof (void *) / sizeof (digit_t)) % 2 != 0)
18 abort ();
20 for (i = 0, j = 0; i < sizeof (size_t); ++i)
22 j *= MAX_NUM;
23 j += i;
26 big_endian_p = (((char *)&j)[0] == 0);
27 for (i = 0; i < sizeof (void *) / sizeof (digit_t); ++i)
29 digit_t *digit;
30 digit_t *bias;
31 digit_t *top;
32 unsigned int *countp;
33 void **pointerp;
35 if (big_endian_p)
36 j = sizeof (void *) / sizeof (digit_t) - i;
37 else
38 j = i;
40 memset (count, 0, MAX_NUM * sizeof (unsigned int));
41 bias = ((digit_t *) pointers) + j;
42 top = ((digit_t *) (pointers + n)) + j;
43 for (digit = bias;
44 digit < top;
45 digit += sizeof (void *) / sizeof (digit_t))
46 ++count[*digit];
48 for (countp = count + 1; countp < count + MAX_NUM; ++countp)
49 *countp += countp[-1];
51 for (pointerp = pointers + n - 1; pointerp >= pointers; --pointerp)
52 work[--count[((digit_t *) pointerp)[j]]] = *pointerp;
54 pointerp = pointers;
55 pointers = work;
56 work = pointerp;
60 /* { dg-final { scan-tree-dump-not "base \[^\\n\]*&MEM\\\[" "ivopts" } } */