| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc-details" } */ |
| 3 |
/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Os" "-flto" } } */ |
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
uint16_t crc16_update(uint16_t crc, uint8_t a) { |
| 9 |
int i; |
| 10 |
int b; |
| 11 |
for (i = 0; i < 8; ++i) { |
| 12 |
if ((crc & 1) ^ (a & 1)) |
| 13 |
crc = (crc >> 1) ^ 0xa001; |
| 14 |
else |
| 15 |
crc = (crc >> 1); |
| 16 |
a >>= 1; |
| 17 |
b = crc; // Unused instruction, this is safe to remove. |
| 18 |
} |
| 19 |
printf ("%d", b); |
| 20 |
return crc; |
| 21 |
} |
| 22 |
|
| 23 |
/* { dg-final { scan-tree-dump "crc16_update function maybe contains CRC calculation." "crc" } } */ |
| 24 |
/* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc" } } */ |
| 25 |
/* { dg-final { scan-tree-dump "Bit reversed" "crc" } } */ |
| 26 |
/* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */ |
| 27 |
/* { dg-final { scan-tree-dump "Polynomial's value is \\\{1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1\\\}" "crc" } } */ |