aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-negate-1.c
blob: 00ec8b4c0b97caac3cb72b126fc56b39fde92c55 (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
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */

#define SHIFT ((8*__SIZEOF_INT__)-1)

int test_rshift_1(int x)
{
  int t = x >> SHIFT;
  return -t;
}

int test_rshift_2(int x)
{
  unsigned int t = (unsigned int)x >> SHIFT;
  return -t;
}

int test_rshift_3(int x)
{
  int t = (unsigned int)x >> SHIFT;
  return -t;
}

int test_rshift_4(int x)
{
  unsigned int t = x >> SHIFT;
  return -t;
}

double test_mul_1(double x)
{
  double t = -5.0 * x;
  return -t;
}

double test_mul_2(double x, double y)
{
  double t1 = -x;
  double t2 = t1 * y;
  return -t2;
}

double test_rdiv_1(double x, double y)
{
  double t1 = -x;
  double t2 = t1 / y;
  return -t2;
}

double test_rdiv_2(double x, double y)
{
  double t1 = -y;
  double t2 = x / t1;
  return -t2;
}

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