Debian Codegraph @

gcc/testsuite/gcc.dg/crc-not-crc-2.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc -O2" } */
3
4 #include <stdint.h>
5
6 typedef uint8_t crc;
7 #define TOPBIT (1 << 7)
8
9 //shift not by one
10 crc
11 notCrc(uint8_t const message[], int nBytes) {
12 crc remainder = 0;
13 for (int byte = 0; byte < nBytes; ++byte) {
14 remainder ^= message[byte] ;
15 for (uint8_t bit = 8; bit > 0; --bit) {
16 if (remainder & TOPBIT) {
17 remainder = (remainder << 3) ^ 1234;
18 } else {
19 remainder = (remainder << 9);
20 }
21 }
22 }
23 return (remainder);
24 }
25
26 /* { dg-final { scan-tree-dump-times "notCrc function maybe contains CRC calculation" 0 "crc" } } */
27