| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -msse2 -ftree-vectorize -march=nocona" } */ |
| 3 |
|
| 4 |
typedef __SIZE_TYPE__ size_t; |
| 5 |
extern void *malloc (size_t); |
| 6 |
extern void free (void *); |
| 7 |
|
| 8 |
typedef struct _Resource |
| 9 |
{ |
| 10 |
struct _Resource *next; |
| 11 |
unsigned int id; |
| 12 |
} ResourceRec, *ResourcePtr; |
| 13 |
|
| 14 |
typedef struct _ClientResource |
| 15 |
{ |
| 16 |
ResourcePtr *resources; |
| 17 |
int elements; |
| 18 |
int buckets; |
| 19 |
int hashsize; |
| 20 |
} ClientResourceRec; |
| 21 |
|
| 22 |
static ClientResourceRec clientTable[256]; |
| 23 |
int Hash (int, unsigned int); |
| 24 |
|
| 25 |
void |
| 26 |
RebuildTable (int client) |
| 27 |
{ |
| 28 |
int j; |
| 29 |
ResourcePtr res, next; |
| 30 |
ResourcePtr **tails, *resources; |
| 31 |
ResourcePtr **tptr, *rptr; |
| 32 |
|
| 33 |
j = 2 * clientTable[client].buckets; |
| 34 |
|
| 35 |
tails = |
| 36 |
(ResourcePtr **) malloc ((unsigned long) (j * sizeof (ResourcePtr *))); |
| 37 |
resources = |
| 38 |
(ResourcePtr *) malloc ((unsigned long) (j * sizeof (ResourcePtr))); |
| 39 |
|
| 40 |
for (rptr = resources, tptr = tails; --j >= 0; rptr++, tptr++) |
| 41 |
{ |
| 42 |
*rptr = ((ResourcePtr) ((void *) 0)); |
| 43 |
*tptr = rptr; |
| 44 |
} |
| 45 |
|
| 46 |
clientTable[client].hashsize++; |
| 47 |
for (j = clientTable[client].buckets, |
| 48 |
rptr = clientTable[client].resources; --j >= 0; rptr++) |
| 49 |
{ |
| 50 |
for (res = *rptr; res; res = next) |
| 51 |
{ |
| 52 |
next = res->next; |
| 53 |
res->next = ((ResourcePtr) ((void *) 0)); |
| 54 |
tptr = &tails[Hash (client, res->id)]; |
| 55 |
**tptr = res; |
| 56 |
*tptr = &res->next; |
| 57 |
} |
| 58 |
} |
| 59 |
free ((void *) tails); |
| 60 |
clientTable[client].buckets *= 2; |
| 61 |
free ((void *) clientTable[client].resources); |
| 62 |
clientTable[client].resources = resources; |
| 63 |
} |
| 64 |
|
| 65 |
/* { dg-final { scan-assembler-not "movlps" } } */ |