| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
|
| 5 |
#define NUM_OF_STATES 4 |
| 6 |
typedef unsigned int entry_t[2]; |
| 7 |
typedef struct entries_item { entry_t metricEntries_[0]; } entries_item_t; |
| 8 |
|
| 9 |
void __attribute__((noinline,noclone)) |
| 10 |
test_00(size_t numOfStates, entries_item_t* p_bm, |
| 11 |
const unsigned int* polyArray, |
| 12 |
size_t polyArraySize) |
| 13 |
{ |
| 14 |
size_t idx; |
| 15 |
unsigned int hlp0, hlp1; |
| 16 |
for (idx = 0; idx < numOfStates; ++idx) |
| 17 |
{ |
| 18 |
size_t idy; |
| 19 |
|
| 20 |
hlp0 = (idx << 1) | 0x00; |
| 21 |
hlp1 = (idx << 1) | 0x01; |
| 22 |
p_bm->metricEntries_[idx][0] = 0; |
| 23 |
p_bm->metricEntries_[idx][1] = 0; |
| 24 |
for (idy = 0; idy < polyArraySize; ++idy) |
| 25 |
{ |
| 26 |
p_bm->metricEntries_[idx][0] |
| 27 |
|= __builtin_parity(hlp0 & polyArray[idy]) << idy; |
| 28 |
p_bm->metricEntries_[idx][1] |
| 29 |
|= __builtin_parity(hlp1 & polyArray[idy]) << idy; |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
int main() |
| 35 |
{ |
| 36 |
unsigned int polyArray[] = { 0x07, 0x05 }; |
| 37 |
entries_item_t* pBranchMetrics; |
| 38 |
pBranchMetrics = malloc(sizeof(entry_t) * NUM_OF_STATES); |
| 39 |
test_00(NUM_OF_STATES, pBranchMetrics, polyArray, |
| 40 |
sizeof(polyArray) / sizeof(polyArray[0])); |
| 41 |
if (pBranchMetrics->metricEntries_[0][0] != 0 |
| 42 |
|| pBranchMetrics->metricEntries_[0][1] != 3 |
| 43 |
|| pBranchMetrics->metricEntries_[1][0] != 1 |
| 44 |
|| pBranchMetrics->metricEntries_[1][1] != 2 |
| 45 |
|| pBranchMetrics->metricEntries_[2][0] != 3 |
| 46 |
|| pBranchMetrics->metricEntries_[2][1] != 0 |
| 47 |
|| pBranchMetrics->metricEntries_[3][0] != 2 |
| 48 |
|| pBranchMetrics->metricEntries_[3][1] != 1) |
| 49 |
abort (); |
| 50 |
free(pBranchMetrics); |
| 51 |
return 0; |
| 52 |
} |