aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr109906.c
blob: 9aa015d8c65c56d0e2572bbd44d082ead2fb64e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* PR tree-optimization/109906 */
/* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-optimized-raw" } */
/* { dg-require-effective-target int32 } */

/* Implementation of rotate right operation */
static inline
unsigned rrotate(unsigned x, int t)
{
  if (t >= 32) __builtin_unreachable();
  unsigned tl = x >> (t);
  unsigned th = x << (32 - t);
  return tl | th;
}

/* Here rotate left is achieved by doing rotate right by (32 - x) */
unsigned rotateleft(unsigned t, int x)
{
  return rrotate (t, 32 - x);
}

/* Implementation of rotate left operation */
static inline
unsigned lrotate(unsigned x, int t)
{
  if (t >= 32) __builtin_unreachable();
  unsigned tl = x << (t);
  unsigned th = x >> (32 - t);
  return tl | th;
}

/* Here rotate right is achieved by doing rotate left by (32 - x) */
unsigned rotateright(unsigned t, int x)
{
  return lrotate (t, 32 - x);
}

/* Shouldn't have instruction for (32 - x). */
/* { dg-final { scan-tree-dump-not "minus_expr" "optimized" } } */
/* { dg-final { scan-tree-dump "rrotate_expr" "optimized" } } */
/* { dg-final { scan-tree-dump "lrotate_expr" "optimized" } } */