| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Os" "-O3" "-flto" } } */ |
| 4 |
|
| 5 |
/* With -O3 the cycles is split into 2, |
| 6 |
and one of them calculates CRC (when data != 0). |
| 7 |
Thus, when compiling with -O3 there is CRC. */ |
| 8 |
|
| 9 |
#include <stdint.h> |
| 10 |
|
| 11 |
uint8_t not_crc(uint8_t crc, uint8_t data) { |
| 12 |
crc = crc ^ data; |
| 13 |
|
| 14 |
for (uint8_t i = 0, n = 0; i < 8; i++, n++) { |
| 15 |
if ((crc & 0x01) && data) |
| 16 |
crc = (crc >> 1) ^ 0x8C; |
| 17 |
else |
| 18 |
crc >>= 1; |
| 19 |
} |
| 20 |
return crc; |
| 21 |
} |
| 22 |
|
| 23 |
/* { dg-final { scan-tree-dump-times "calculates CRC!" 0 "crc" } } */ |