summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gcc.dg/20020607-2.c
blob: 239aa9b388055d64529958d5baf192c8e64d6437 (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
/* Copyright (C) 2002 Free Software Foundation.

   Test for correctness of floating point comparisons.

   Written by Roger Sayle, 3rd June 2002.  */

/* { dg-do run } */
/* { dg-options "-O2 -ffast-math" } */

extern void abort (void);

int test1 (double x, int ok)
{
  if ((x - 1.0) > 0.0)
    {
      if (!ok) abort ();
    }
  else
    if (ok) abort ();
}

int test1f (float x, int ok)
{
  if ((x - 1.0f) > 0.0f)
    {
      if (!ok) abort ();
    }
  else
    if (ok) abort ();
}

int test2 (double x, int ok)
{
  if ((x + 1.0) < 0.0)
    {
      if (!ok) abort ();
    }
  else
    if (ok) abort ();
}

int test2f (float x, int ok)
{
  if ((x + 1.0f) < 0.0f)
    {
      if (!ok) abort ();
    }
  else
    if (ok) abort ();
}


int
main ()
{
  test1 (-2.0, 0);
  test1 ( 0.0, 0);
  test1 ( 2.0, 1);

  test1f (-2.0f, 0);
  test1f ( 0.0f, 0);
  test1f ( 2.0f, 1);

  test2 (-2.0, 1);
  test2 ( 0.0, 0);
  test2 ( 2.0, 0);

  test2f (-2.0f, 1);
  test2f ( 0.0f, 0);
  test2f ( 2.0f, 0);

  return 0;
}

OpenPOWER on IntegriCloud