summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/forwprop-33.c
blob: c7124deee11f3655d7c50bd9605bb7caddba6470 (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
66
67
68
69
70
71
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-forwprop3" } */

unsigned short
test1 (unsigned short a)
{
  a ^= 0x4002;
  a >>= 1;
  a |= 0x8000; /* Simplify to ((a >> 1) ^ 0xa001).  */
  return a;
}
/* { dg-final { scan-tree-dump "\\^ 40961" "forwprop3" } } */

unsigned short
test2 (unsigned short a)
{
  a |= 0x4002;
  a <<= 1;
  a ^= 0x0001; /* Simplify to ((a << 1) | 0x8005).  */
  return a;
}
/* { dg-final { scan-tree-dump "\\| 32773" "forwprop3" } } */

unsigned short
test3 (unsigned short a)
{
  a &= 0xd123;
  a ^= 0x6040;
  a |= 0xc031; /* Simplify to ((a & 0xd123) | 0xe071).  */
  return a;
}
/* { dg-final { scan-tree-dump "\\| 57457" "forwprop3" } } */

unsigned short
test4 (unsigned short a)
{
  a ^= 0x8002;
  a >>= 1;
  a |= 0x8000;
  return a;
}
/* { dg-final { scan-tree-dump "\\^ 49153" "forwprop3" } } */

unsigned short
test5 (unsigned short a)
{
  a ^= 0x8002;
  a >>= 1;
  a |= 0x8001; /* Only move shift inward: (((a >> 1) ^ 0x4001) | 0x8001).  */
  return a;
}
/* { dg-final { scan-tree-dump "\\^ 16385" "forwprop3" } } */
/* { dg-final { scan-tree-dump "\\| 32769" "forwprop3" } } */

short
test6 (short a)
{
  a &= 0x7fff;
  a >>= 2;
  return a;
}
/* { dg-final { scan-tree-dump "\\& 8191" "forwprop3" } } */

short
test7 (short a)
{
  a &= 0x8fff;
  a >>= 2;
  return a;
}
/* { dg-final { scan-tree-dump "\\& -7169" "forwprop3" } } */