Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details -O2" } */
3
4 // File - hash.c.i.
5 /* We don't support cases with multiple conditional branches in the loop. */
6 #include <stdint.h>
7 typedef struct _crc_calculator {
8 uint32_t remainder;
9 uint32_t trunc_poly;
10 uint32_t bits;
11 uint32_t table[256];
12 uint32_t final_result_mask;
13 } CRC_CALCULATOR;
14
15 void crc_calculator_init_table(CRC_CALCULATOR *p_crc_calculator) {
16 const uint32_t high_bit = 1 << (p_crc_calculator->bits - 1);
17 const uint32_t byte_high_bit = 1 << (8 - 1);
18
19 for (uint32_t value = 0; value < 256; value++) {
20 uint32_t remainder = 0;
21 for (uint8_t mask = byte_high_bit; mask != 0; mask >>= 1) {
22 if (value & mask) {
23 remainder ^= high_bit;
24 }
25
26 if (remainder & high_bit) {
27 remainder <<= 1;
28 remainder ^= p_crc_calculator->trunc_poly;
29 } else {
30 remainder <<= 1;
31 }
32 }
33 p_crc_calculator->table[value] = remainder;
34 }
35 }