| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc-details -O2" } */ |
| 3 |
|
| 4 |
// crc.ii, CRC16 |
| 5 |
#include <stdio.h> |
| 6 |
typedef unsigned short u16; |
| 7 |
|
| 8 |
void GenerateCRC32Table(u16 polynomial, u16 *table) |
| 9 |
{ |
| 10 |
for (u16 i = 0; i <= 255; i++) { |
| 11 |
u16 crc = i; |
| 12 |
for (u16 j = 0; j < 8; j++) { // latch's next bb is loop header |
| 13 |
crc = (crc >> 1) ^ ((crc & 1) ? 0x2342 : 0); |
| 14 |
} |
| 15 |
table[i] = crc; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
int main () |
| 20 |
{ |
| 21 |
u16 table [256]; |
| 22 |
GenerateCRC32Table (0x4, table); |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
/* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */ |