Debian Codegraph @

gcc/testsuite/gcc.dg/torture/crc-3.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Os" "-O3" "-flto" } } */
4 /* { dg-require-effective-target int32plus } */
5
6 //We don't verify this case as for the CRC unsigned int (32 bit) is used and
7 // the polynomial fits into 16 bit. Also, as the loop's iteration number and
8 // data's size differ.
9
10 unsigned short crc16 (char *data_p, unsigned short length) {
11 unsigned char i;
12 unsigned int data;
13 unsigned int crc = 0xffff;
14
15 if (length == 0)
16 return (~crc);
17
18 do {
19 for (i = 0, data = (unsigned int) 0xff & *data_p++;
20 i < 8;
21 i++, data >>= 1) {
22 if ((crc & 0x0001) ^ (data & 0x0001))
23 crc = (crc >> 1) ^ 0x8408;
24 else crc >>= 1;
25 }
26 } while (--length);
27
28 crc = ~crc;
29 data = crc;
30 crc = (crc << 8) | (data >> 8 & 0xff);
31
32 return (crc);
33 }
34
35 /* { dg-final { scan-tree-dump "function maybe contains CRC calculation." "crc" } } */
36 /* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc" } } */
37 /* { dg-final { scan-tree-dump "Bit reversed" "crc" } } */
38 /* { dg-final { scan-tree-dump "Loop iteration number and data's size differ." "crc" } } */