OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [ieee/] [fp-cmp-5.c] - Blame information for rev 378

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Like fp-cmp-4.c, but test that the setcc patterns are correct.  */
2
 
3
static int
4
test_isunordered(double x, double y)
5
{
6
  return __builtin_isunordered(x, y);
7
}
8
 
9
static int
10
test_not_isunordered(double x, double y)
11
{
12
  return !__builtin_isunordered(x, y);
13
}
14
 
15
static int
16
test_isless(double x, double y)
17
{
18
  return __builtin_isless(x, y);
19
}
20
 
21
static int
22
test_not_isless(double x, double y)
23
{
24
  return !__builtin_isless(x, y);
25
}
26
 
27
static int
28
test_islessequal(double x, double y)
29
{
30
  return __builtin_islessequal(x, y);
31
}
32
 
33
static int
34
test_not_islessequal(double x, double y)
35
{
36
  return !__builtin_islessequal(x, y);
37
}
38
 
39
static int
40
test_isgreater(double x, double y)
41
{
42
  return __builtin_isgreater(x, y);
43
}
44
 
45
static int
46
test_not_isgreater(double x, double y)
47
{
48
  return !__builtin_isgreater(x, y);
49
}
50
 
51
static int
52
test_isgreaterequal(double x, double y)
53
{
54
  return __builtin_isgreaterequal(x, y);
55
}
56
 
57
static int
58
test_not_isgreaterequal(double x, double y)
59
{
60
  return !__builtin_isgreaterequal(x, y);
61
}
62
 
63
static int
64
test_islessgreater(double x, double y)
65
{
66
  return __builtin_islessgreater(x, y);
67
}
68
 
69
static int
70
test_not_islessgreater(double x, double y)
71
{
72
  return !__builtin_islessgreater(x, y);
73
}
74
 
75
static void
76
one_test(double x, double y, int expected,
77
         int (*pos) (double, double), int (*neg) (double, double))
78
{
79
  if ((*pos)(x, y) != expected)
80
    abort ();
81
  if ((*neg)(x, y) != !expected)
82
    abort ();
83
}
84
 
85
#define NAN (0.0 / 0.0)
86
 
87
int
88
main()
89
{
90
  struct try
91
  {
92
    double x, y;
93
    int result[6];
94
  };
95
 
96
  static struct try const data[] =
97
  {
98
    { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },
99
    { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },
100
    { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },
101
    { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
102
    { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
103
    { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
104
  };
105
 
106
  struct test
107
  {
108
    int (*pos)(double, double);
109
    int (*neg)(double, double);
110
  };
111
 
112
  static struct test const tests[] =
113
  {
114
    { test_isunordered, test_not_isunordered },
115
    { test_isless, test_not_isless },
116
    { test_islessequal, test_not_islessequal },
117
    { test_isgreater, test_not_isgreater },
118
    { test_isgreaterequal, test_not_isgreaterequal },
119
    { test_islessgreater, test_not_islessgreater }
120
  };
121
 
122
  const int n = sizeof(data) / sizeof(data[0]);
123
  int i, j;
124
 
125
  for (i = 0; i < n; ++i)
126
    for (j = 0; j < 6; ++j)
127
      one_test (data[i].x, data[i].y, data[i].result[j],
128
                tests[j].pos, tests[j].neg);
129
 
130
  exit (0);
131
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.