| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc -O2" } */ |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
|
| 6 |
uint16_t not_crcu8 (uint8_t data, uint16_t crc) { |
| 7 |
uint8_t i = 0, x16 = 0, carry = 0; |
| 8 |
for (i = 0; i < 8; i++) { |
| 9 |
x16 = (uint8_t) ((data & 2) ^ ((uint8_t) crc & 2)); |
| 10 |
data >>= 1; |
| 11 |
if (x16 == 2) { |
| 12 |
crc ^= 0x4002; |
| 13 |
carry = 1; |
| 14 |
} else |
| 15 |
carry = 0; |
| 16 |
crc >>= 1; |
| 17 |
if (carry) |
| 18 |
crc |= 0x8000; |
| 19 |
else |
| 20 |
crc &= 0x7fff; |
| 21 |
} |
| 22 |
return crc; |
| 23 |
} |
| 24 |
|
| 25 |
/* { dg-final { scan-tree-dump-times "calculates CRC!" 0 "crc" } } */ |