diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-04-26 16:49:10 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-04-26 16:49:10 +0000 |
commit | f88523e5bcc718aa4265f320014ab818ae700e30 (patch) | |
tree | 805faaf806794221b6d0f6b5c373c8e0e074ebf2 /gcc/tree.c | |
parent | ffb77fd6c7c5e6cebdbb03750833793749d7402e (diff) | |
download | gcc-f88523e5bcc718aa4265f320014ab818ae700e30.zip gcc-f88523e5bcc718aa4265f320014ab818ae700e30.tar.gz gcc-f88523e5bcc718aa4265f320014ab818ae700e30.tar.bz2 |
tree.h (crc32_unsigned_n): Declare.
* tree.h (crc32_unsigned_n): Declare.
(crc32_unsigned, crc32_unsigned): Make inline.
* tree.c (crc32_unsigned_bits): Replace with ...
(crc32_unsigned_n): ... this.
(crc32_unsigned, crc32_byte): Remove.
(crc32_string): Remove unnecessary braces.
From-SVN: r247281
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 52 |
1 files changed, 23 insertions, 29 deletions
@@ -9611,38 +9611,34 @@ dump_tree_statistics (void) #define FILE_FUNCTION_FORMAT "_GLOBAL__%s_%s" -/* Generate a crc32 of a byte. */ +/* Generate a crc32 of the low BYTES bytes of VALUE. */ -static unsigned -crc32_unsigned_bits (unsigned chksum, unsigned value, unsigned bits) +unsigned +crc32_unsigned_n (unsigned chksum, unsigned value, unsigned bytes) { - unsigned ix; - - for (ix = bits; ix--; value <<= 1) + /* This relies on the raw feedback's top 4 bits being zero. */ +#define FEEDBACK(X) ((X) * 0x04c11db7) +#define SYNDROME(X) (FEEDBACK ((X) & 1) ^ FEEDBACK ((X) & 2) \ + ^ FEEDBACK ((X) & 4) ^ FEEDBACK ((X) & 8)) + static const unsigned syndromes[16] = { - unsigned feedback; - - feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0; - chksum <<= 1; - chksum ^= feedback; - } - return chksum; -} + SYNDROME(0x0), SYNDROME(0x1), SYNDROME(0x2), SYNDROME(0x3), + SYNDROME(0x4), SYNDROME(0x5), SYNDROME(0x6), SYNDROME(0x7), + SYNDROME(0x8), SYNDROME(0x9), SYNDROME(0xa), SYNDROME(0xb), + SYNDROME(0xc), SYNDROME(0xd), SYNDROME(0xe), SYNDROME(0xf), + }; +#undef FEEDBACK +#undef SYNDROME -/* Generate a crc32 of a 32-bit unsigned. */ - -unsigned -crc32_unsigned (unsigned chksum, unsigned value) -{ - return crc32_unsigned_bits (chksum, value, 32); -} + value <<= (32 - bytes * 8); + for (unsigned ix = bytes * 2; ix--; value <<= 4) + { + unsigned feedback = syndromes[((value ^ chksum) >> 28) & 0xf]; -/* Generate a crc32 of a byte. */ + chksum = (chksum << 4) ^ feedback; + } -unsigned -crc32_byte (unsigned chksum, char byte) -{ - return crc32_unsigned_bits (chksum, (unsigned) byte << 24, 8); + return chksum; } /* Generate a crc32 of a string. */ @@ -9651,9 +9647,7 @@ unsigned crc32_string (unsigned chksum, const char *string) { do - { - chksum = crc32_byte (chksum, *string); - } + chksum = crc32_byte (chksum, *string); while (*string++); return chksum; } |