gcc/testsuite/gcc.dg/crc-not-crc-14.c
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-fdump-tree-crc -O2" } */ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | uint8_t not_crc(uint8_t crc, uint8_t data) { |
| 7 | crc = crc ^ data; |
| 8 | |
| 9 | for (uint8_t i = 0, n = 0; i < 8; i++, n++) { |
| 10 | if (data > i) |
| 11 | crc = 8; |
| 12 | if (crc & 0x01) |
| 13 | crc = (crc >> 1) ^ 0x8C; |
| 14 | else |
| 15 | crc >>= 1; |
| 16 | } |
| 17 | return crc; |
| 18 | } |
| 19 | |
| 20 | /* { dg-final { scan-tree-dump-times "calculates CRC!" 0 "crc" } } */ |