aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-condnot-1.c
blob: 75d558c2686ebe0b2b7b256e07aa71eac29d3bb2 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

int test_i0(int x)
{
  return x != 0 ? ~x : ~0;
}

int test_i1(int x)
{
  return x != 1 ? ~x : -2;
}

int test_im1(int x)
{
  return x != ~0 ? ~x : 0;
}

unsigned int test_u0(unsigned int x)
{
  return x != 0 ? ~x : ~0;
}

unsigned int test_u1(unsigned int x)
{
  return x != 1 ? ~x : ~1u;
}

unsigned int test_um1(unsigned int x)
{
  return x != ~0u ? ~x : 0;
}

signed char test_c0(signed char x)
{
  return x != 0 ? ~x : -1;
}

signed char test_c1(signed char x)
{
  return x != 1 ? ~x : -2;
}

signed char test_cm1(signed char x)
{
  return x != -1 ? ~x : 0;
}

signed char test_cm128(signed char x)
{
  return x != -128 ? ~x : 127;
}

signed char test_c127(signed char x)
{
  return x != 127 ? ~x : -128;
}

unsigned char test_uc0(unsigned char x)
{
  return x != 0 ? ~x : 255;
}

unsigned char test_uc1(unsigned char x)
{
  return x != 1 ? ~x : 254;
}

unsigned char test_uc127(unsigned char x)
{
  return x != 127 ? ~x : 128;
}

unsigned char test_uc128(unsigned char x)
{
  return x != 128 ? ~x : 127;
}

unsigned char test_ucm1(unsigned char x)
{
  return x != 255 ? ~x : 0;
}

/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */