Debian Codegraph @

gcc/testsuite/gcc.dg/crc-from-fedora-packages-20.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details -O2" } */
3 /* { dg-require-effective-target int32plus } */
4
5 // File - scorelayout.i
6 // It is verified by the pass if we don't filter out the cases when data's size
7 // and loop iteration count differ.
8 #include <stdlib.h>
9 typedef unsigned char guchar;
10 typedef unsigned int guint32;
11 guint32
12 bit_reverse (guint32 x)
13 {
14 x = ((x & 0x55555555) << 1) | ((x >> 1) & 0x55555555);
15 x = ((x & 0x33333333) << 2) | ((x >> 2) & 0x33333333);
16 x = ((x & 0x0F0F0F0F) << 4) | ((x >> 4) & 0x0F0F0F0F);
17 x = (x << 24) | ((x & 0xFF00) << 8) | ((x >> 8) & 0xFF00) | (x >> 24);
18 return x;
19 }
20
21 guint32
22 crc32 (guchar * message)
23 {
24 if (sizeof (int) < 4)
25 exit (0);
26
27 int i, j;
28 guint32 byte, crc;
29 i = 0;
30 crc = 0xFFFFFFFF;
31 while (message[i] != 0)
32 {
33 byte = message[i];
34 byte = bit_reverse (byte);
35 for (j = 0; j <= 7; j++)
36 {
37 if ((int) (crc ^ byte) < 0)
38 crc = (crc << 1) ^ 0x04C11DB7;
39 else
40 crc = crc << 1;
41 byte = byte << 1;
42 }
43 i = i + 1;
44 }
45 return bit_reverse (~crc);
46 }
47
48 /* { dg-final { scan-tree-dump "Loop iteration number and data's size differ." "crc" } } */