]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/fold-notrotate-1.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / fold-notrotate-1.c
1 /* { dg-do compile } */
2 /* { dg-options "-O -fdump-tree-optimized" } */
3
4 #define INT_BITS (sizeof (int) * __CHAR_BIT__)
5 #define ROL(x, y) ((x) << (y) | (x) >> (INT_BITS - (y)))
6 #define ROR(x, y) ((x) >> (y) | (x) << (INT_BITS - (y)))
7
8 unsigned
9 rol (unsigned a, unsigned b)
10 {
11 return ~ROL (~a, b);
12 }
13
14 unsigned int
15 ror (unsigned a, unsigned b)
16 {
17 return ~ROR (~a, b);
18 }
19
20 int
21 rol_conv1 (int a, unsigned b)
22 {
23 return ~(int)ROL((unsigned)~a, b);
24 }
25
26 int
27 rol_conv2 (int a, unsigned b)
28 {
29 return ~ROL((unsigned)~a, b);
30 }
31
32 int
33 rol_conv3 (unsigned a, unsigned b)
34 {
35 return ~(int)ROL(~a, b);
36 }
37
38 #define LONG_BITS (sizeof (long) * __CHAR_BIT__)
39 #define ROLL(x, y) ((x) << (y) | (x) >> (LONG_BITS - (y)))
40 #define RORL(x, y) ((x) >> (y) | (x) << (LONG_BITS - (y)))
41
42 unsigned long
43 roll (unsigned long a, unsigned long b)
44 {
45 return ~ROLL (~a, b);
46 }
47
48 unsigned long
49 rorl (unsigned long a, unsigned long b)
50 {
51 return ~RORL (~a, b);
52 }
53
54 /* { dg-final { scan-tree-dump-not "~" "optimized" } } */