Debian Codegraph @

gcc/testsuite/gcc.dg/torture/crc-side-instr-6.c

raw
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 typedef unsigned short ee_u16;
8 typedef unsigned char ee_u8;
9
10 int a;
11 ee_u16 crcu8 (ee_u8 data, ee_u16 crc) {
12 ee_u8 i = 0, x16 = 0, carry = 0;
13 for (i = 0; i < 8; i++) {
14 a++; // this is moved outside of the loop
15 x16 = (ee_u8) ((data & 1) ^ ((ee_u8) crc & 1));
16 data >>= 1;
17 if (x16 == 1) {
18 crc ^= 0x4002;
19 carry = 1;
20 } else
21 carry = 0;
22 crc >>= 1;
23 if (carry)
24 crc |= 0x8000;
25 else
26 crc &= 0x7fff;
27 }
28 return crc;
29 }
30
31 int main()
32 {
33 printf ("%04X\n", crcu8 (0, 0xaa));
34 printf ("%d", a);
35 }
36
37
38 /* { dg-final { scan-tree-dump "crcu8 function maybe contains CRC calculation." "crc" } } */
39 /* { dg-final { scan-tree-dump "Loop iteration number is 7" "crc" } } */
40 /* { dg-final { scan-tree-dump "Bit reversed" "crc" } } */
41 /* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */
42 /* { dg-final { scan-tree-dump "Polynomial's value is \\\{\[0, \]*1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1\\\}" "crc" } } */