aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/shifts-3.c
blob: 2b1cf703b4aca05d7f1292cd0847f24c09adef32 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* { dg-options "-O2 -fdump-tree-optimized-raw" } */

unsigned int
f1 (unsigned int x)
{
  if (x & 3)
    __builtin_unreachable ();
  x >>= 2;
  return x * 20;
}

unsigned int
f2 (unsigned int x)
{
  if (x & 3)
    __builtin_unreachable ();
  unsigned char y = x;
  y >>= 2;
  return y * 36;
}

unsigned long
f3 (unsigned int x)
{
  if (x & 3)
    __builtin_unreachable ();
  x >>= 2;
  return (unsigned long) x * 88;
}

int
f4 (int x)
{
  if (x & 15)
    __builtin_unreachable ();
  x >>= 4;
  return x * 48;
}

unsigned int
f5 (int x)
{
  if (x & 31)
    __builtin_unreachable ();
  x >>= 5;
  return x * 3200;
}

unsigned int
f6 (unsigned int x)
{
  if (x & 1)
    __builtin_unreachable ();
  x >>= 1;
  return x * (~0U / 3 & -2);
}

/* { dg-final { scan-tree-dump-not {<[a-z]*_div_expr,} "optimized" } } */
/* { dg-final { scan-tree-dump-not {<rshift_expr,} "optimized" } } */
/* { dg-final { scan-tree-dump {<mult_expr, [^,]*, [^,]*, 5,} "optimized" } } */
/* { dg-final { scan-tree-dump {<(?:widen_)?mult_expr, [^,]*, [^,]*, 9,} "optimized" } } */
/* { dg-final { scan-tree-dump {<(?:widen_)?mult_expr, [^,]*, [^,]*, 22,} "optimized" } } */
/* { dg-final { scan-tree-dump {<mult_expr, [^,]*, [^,]*, 3,} "optimized" } } */
/* { dg-final { scan-tree-dump {<mult_expr, [^,]*, [^,]*, 100,} "optimized" } } */
/* { dg-final { scan-tree-dump {<mult_expr, [^,]*, [^,]*, 715827882,} "optimized" { target int32 } } } */