Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Os" "-flto" } } */
4
5 typedef unsigned short ee_u16;
6 typedef unsigned char ee_u8;
7
8 int a;
9 ee_u16 crcu8 (ee_u8 data, ee_u16 crc) {
10 ee_u16 i = 0, x16 = 0, carry = 0;
11 int c;
12 for (i = 0; i < 8; i++) {
13 c += i*2; // In compiled code, it is moved outside of the loop.
14 x16 = (ee_u8) ((data & 1) ^ ((ee_u8) crc & 1));
15 data >>= 1;
16 if (x16 == 1) {
17 crc ^= 0x4002;
18 carry = 1;
19 } else
20 carry = 0;
21 crc >>= 1;
22 a = c;
23 if (carry)
24 {
25 crc |= 0x8000;
26 }
27 else
28 crc &= 0x7fff;
29 }
30 return crc;
31 }
32
33 /* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */