diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/crc-26.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/crc-26.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/crc-26.c b/gcc/testsuite/gcc.dg/crc-26.c new file mode 100644 index 00000000000..298fb39c375 --- /dev/null +++ b/gcc/testsuite/gcc.dg/crc-26.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-crc-details" } */ + +#include <stdio.h> + +typedef unsigned char uint8_t; + +uint8_t gencrc (uint8_t *data) +{ + uint8_t crc = 0xff; + size_t j; + crc ^= *data; + for (j = 0; j < 8; j++) + { + if ((crc & 0x80) != 0) + crc = (uint8_t) ((crc << 1) ^ 0x31); + else + crc <<= 1; + } + return crc; +} + +/* { dg-final { scan-tree-dump "gencrc function maybe calculates CRC and returns it." "crc"} } */ +/* { dg-final { scan-tree-dump "Return size is 8" "crc"} } */ +/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc"} } */ +/* { dg-final { scan-tree-dump "Bit forward" "crc"} } */ +/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \\\^ \[a-zA-Z0-9_\]+\(\\\(\[a-zA-Z\]\\\)\)?;" "crc" } } */ +/* { dg-final { scan-tree-dump "Executing \[a-zA-Z_\]\[a-zA-Z0-9_\]* = \[a-zA-Z_\]\[a-zA-Z0-9_\]* \(<<|>>\) \[0-9]+;" "crc" } } */
\ No newline at end of file |