OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [compare-rel.h] - Blame information for rev 853

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

Line No. Rev Author Line
1 149 jeremybenn
/* Basic test of runtime relational comparisons using simple values that
2
   are not affected by rounding.  */
3
 
4
#include <stdlib.h>
5
 
6
static int failcnt;
7
 
8
#define PASTE2(A,B) A ## B
9
#define PASTE(A,B) PASTE2(A,B)
10
 
11
#ifdef DBG
12
#include <stdio.h>
13
#define FAILURE(OP,KIND) \
14
  { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \
15
    failcnt++; }
16
#else
17
#define FAILURE(OP,KIND) abort ();
18
#endif
19
 
20
#ifndef WIDTH
21
#error define WIDTH as decimal float size in bytes
22
#endif
23
 
24
#if WIDTH == 32
25
#define DTYPE _Decimal32
26
#define SUFFIX DF
27
#elif WIDTH == 64
28
#define DTYPE _Decimal64
29
#define SUFFIX DD
30
#elif WIDTH == 128
31
#define DTYPE _Decimal128
32
#define SUFFIX DL
33
#elif WIDTH == 0
34
/* This is for testing the test using a type known to work.  */
35
#define DTYPE double
36
#define SUFFIX
37
#else
38
#error invalid width for decimal float type
39
#endif
40
 
41
DTYPE m_two = PASTE(-2.0, SUFFIX);
42
DTYPE m_one = PASTE(-1.0, SUFFIX);
43
DTYPE zero  = PASTE(0.0, SUFFIX);
44
DTYPE one   = PASTE(1.0, SUFFIX);
45
DTYPE two   = PASTE(2.0, SUFFIX);
46
 
47
void
48
test_compares (void)
49
{
50
  DTYPE x = one;
51
  DTYPE y = zero;
52
  DTYPE z = m_one;
53
 
54
  /* Less than or equal to: comparisons against equal values.  */
55
 
56
  if (! (x <= one))   FAILURE ("<=", "equal")
57
  if (! (y <= zero))  FAILURE ("<=", "equal")
58
  if (! (z <= m_one)) FAILURE ("<=", "equal")
59
 
60
  /* Less than or equal to: comparisons against lesser values.  */
61
 
62
  if (x <= m_one)     FAILURE ("<=", "lesser")
63
  if (x <= zero)      FAILURE ("<=", "lesser")
64
  if (y <= m_one)     FAILURE ("<=", "lesser")
65
  if (z <= m_two)     FAILURE ("<=", "lesser")
66
 
67
  /* Less than or equal to: comparisons against greater values.  */
68
 
69
  if (! (x <= two))   FAILURE ("<=", "greater")
70
  if (! (y <= one))   FAILURE ("<=", "greater")
71
  if (! (z <= zero))  FAILURE ("<=", "greater")
72
  if (! (z <= one))   FAILURE ("<=", "greater")
73
 
74
  /* Less than: comparisons against equal values.  */
75
 
76
  if (x < one)        FAILURE ("<", "equal")
77
  if (y < zero)       FAILURE ("<", "equal")
78
  if (z < m_one)      FAILURE ("<", "equal")
79
 
80
  /* Less than: comparisons against lesser values.  */
81
 
82
  if (x < m_one)      FAILURE ("<", "lesser")
83
  if (x < zero)       FAILURE ("<", "lesser")
84
  if (y < m_one)      FAILURE ("<", "lesser")
85
  if (z < m_two)      FAILURE ("<", "lesser")
86
 
87
  /* Less than: comparisons against greater values.  */
88
 
89
  if (! (x < two))    FAILURE ("<", "greater")
90
  if (! (y < one))    FAILURE ("<", "greater")
91
  if (! (z < zero))   FAILURE ("<", "greater")
92
  if (! (z < one))    FAILURE ("<", "greater")
93
 
94
  /* Greater than or equal to: comparisons against equal values.  */
95
 
96
  if (! (x >= one))   FAILURE (">=", "equal")
97
  if (! (y >= zero))  FAILURE (">=", "equal")
98
  if (! (z >= m_one)) FAILURE (">=", "equal")
99
 
100
  /* Greater than or equal to: comparisons against lesser values.  */
101
 
102
  if (! (x >= m_one)) FAILURE (">=", "lesser")
103
  if (! (x >= zero))  FAILURE (">=", "lesser")
104
  if (! (y >= m_one)) FAILURE (">=", "lesser")
105
  if (! (z >= m_two)) FAILURE (">=", "lesser")
106
 
107
  /* Greater than or equal to: comparisons against greater values.  */
108
 
109
  if (x >= two)       FAILURE (">=", "greater")
110
  if (y >= one)       FAILURE (">=", "greater")
111
  if (z >= zero)      FAILURE (">=", "greater")
112
  if (z >= one)       FAILURE (">=", "greater")
113
 
114
  /* Greater than: comparisons against equal values.  */
115
 
116
  if (x > one)        FAILURE (">", "equal")
117
  if (y > zero)       FAILURE (">", "equal")
118
  if (z > m_one)      FAILURE (">", "equal")
119
 
120
  /* Greater than: comparisons against lesser values.  */
121
 
122
  if (! (x > m_one))  FAILURE (">", "lesser")
123
  if (! (x > zero))   FAILURE (">", "lesser")
124
  if (! (y > m_one))  FAILURE (">", "lesser")
125
  if (! (z > m_two))  FAILURE (">", "lesser")
126
 
127
  /* Greater than: comparisons against greater values.  */
128
 
129
  if (x > two)        FAILURE (">", "greater")
130
  if (y > one)        FAILURE (">", "greater")
131
  if (z > zero)       FAILURE (">", "greater")
132
  if (z > one)        FAILURE (">", "greater")
133
 
134
  if (failcnt)
135
    abort ();
136
}

powered by: WebSVN 2.1.0

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