diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/crc-14.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/crc-14.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/crc-14.c b/gcc/testsuite/gcc.dg/crc-14.c new file mode 100644 index 0000000..ab1cf04 --- /dev/null +++ b/gcc/testsuite/gcc.dg/crc-14.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-crc" } */ + +#include <stdint.h> + +//shift and xor only if lsb is 1 +uint16_t not_crc(uint16_t crc, uint8_t a) { + int i; + crc ^= a; + for (i = 0; i < 8; ++i) { + if (crc & 1) + crc = (crc >> 1) ^ 0xA001; + } + return crc; +} + +/* { dg-final { scan-tree-dump-times "Attention! not_crc function calculates CRC." 0 "crc"} } */ + |