| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc-details -O2" } */ |
| 3 |
|
| 4 |
// File - callerid |
| 5 |
|
| 6 |
unsigned short calc_crc(unsigned short crc, unsigned char data) |
| 7 |
{ |
| 8 |
unsigned int i, j, org, dst; |
| 9 |
org = data; |
| 10 |
dst = 0; |
| 11 |
|
| 12 |
for (i = 0; i < 8; i++) { |
| 13 |
org <<= 1; |
| 14 |
dst >>= 1; |
| 15 |
if (org & 0x100) |
| 16 |
dst |= 0x80; |
| 17 |
} |
| 18 |
data = (unsigned char) dst; |
| 19 |
crc ^= (unsigned int) data << (16 - 8); |
| 20 |
for (j = 0; j < 8; j++) { |
| 21 |
if (crc & 0x8000U) |
| 22 |
crc = (crc << 1) ^ 0x1021U ; |
| 23 |
else |
| 24 |
crc <<= 1 ; |
| 25 |
} |
| 26 |
return crc; |
| 27 |
} |
| 28 |
|
| 29 |
/* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */ |