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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [tree-ssa/] [vrp13.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* { dg-do run }  */
2
/* { dg-options -O2 }  */
3
 
4
extern void abort (void);
5
 
6
foo_div (int i, int j)
7
{
8
  int k;
9
 
10
  /* [-INF, -1] / [1, +INF] should not give [-1, -1].  */
11
  if (i <= -1)
12
    if (j >= 1)
13
      {
14
        k = i / j;
15
        if (k == -1)
16
          abort ();
17
 
18
        return k;
19
      }
20
 
21
  /* [-20, -10] / [2, 10] should give [-10, -1].  */
22
  if (i >= -20)
23
    if (i <= -10)
24
      if (j >= 2)
25
        if (j <= 10)
26
          {
27
            k = i / j;
28
            if (k < -10)
29
              link_error ();
30
            if (k > -1)
31
              link_error ();
32
 
33
            return k;
34
          }
35
 
36
  /* [-20, -10] / [-10, -2] should give [1, 10].  */
37
  if (i >= -20)
38
    if (i <= -10)
39
      if (j >= -10)
40
        if (j <= -2)
41
          {
42
            k = i / j;
43
            if (k < 1)
44
              link_error ();
45
            if (k > 10)
46
              link_error ();
47
 
48
            return k;
49
          }
50
 
51
  /* [-20, 10] / [2, 10] should give [-10, 5].  */
52
  if (i >= -20)
53
    if (i <= 10)
54
      if (j >= 2)
55
        if (j <= 10)
56
          {
57
            k = i / j;
58
            if (k < -10)
59
              link_error ();
60
            if (k > 5)
61
              link_error ();
62
 
63
            return k;
64
          }
65
 
66
  /* [-20, 10] / [-10, -2] should give [-5, 10].  */
67
  if (i >= -20)
68
    if (i <= 10)
69
      if (j >= -10)
70
        if (j <= -2)
71
          {
72
            k = i / j;
73
            if (k < -5)
74
              link_error ();
75
            if (k > 10)
76
              link_error ();
77
 
78
            return k;
79
          }
80
 
81
  /* [10, 20] / [2, 10] should give [1, 10].  */
82
  if (i >= 10)
83
    if (i <= 20)
84
      if (j >= 2)
85
        if (j <= 10)
86
          {
87
            k = i / j;
88
            if (k < 1)
89
              link_error ();
90
            if (k > 10)
91
              link_error ();
92
 
93
            return k;
94
          }
95
 
96
  /* [10, 20] / [-10, -2] should give [-10, -1].  */
97
  if (i >= 10)
98
    if (i <= 20)
99
      if (j >= -10)
100
        if (j <= -2)
101
          {
102
            k = i / j;
103
            if (k > -1)
104
              link_error ();
105
            if (k < -10)
106
              link_error ();
107
 
108
            return k;
109
          }
110
 
111
  abort ();
112
}
113
 
114
 
115
foo_mult (int i, int j)
116
{
117
  int k;
118
 
119
  /* [-20, -10] * [2, 10] should give [-200, -20].  */
120
  if (i >= -20)
121
    if (i <= -10)
122
      if (j >= 2)
123
        if (j <= 10)
124
          {
125
            k = i * j;
126
            if (k < -200)
127
              link_error ();
128
            if (k > -20)
129
              link_error ();
130
 
131
            return k;
132
          }
133
 
134
  /* [-20, -10] * [-10, -2] should give [20, 200].  */
135
  if (i >= -20)
136
    if (i <= -10)
137
      if (j >= -10)
138
        if (j <= -2)
139
          {
140
            k = i * j;
141
            if (k < 20)
142
              link_error ();
143
            if (k > 200)
144
              link_error ();
145
 
146
            return k;
147
          }
148
 
149
  /* [-20, 10] * [2, 10] should give [-200, 100].  */
150
  if (i >= -20)
151
    if (i <= 10)
152
      if (j >= 2)
153
        if (j <= 10)
154
          {
155
            k = i * j;
156
            if (k < -200)
157
              link_error ();
158
            if (k > 100)
159
              link_error ();
160
 
161
            return k;
162
          }
163
 
164
  /* [-20, 10] * [-10, -2] should give [-100, 200].  */
165
  if (i >= -20)
166
    if (i <= 10)
167
      if (j >= -10)
168
        if (j <= -2)
169
          {
170
            k = i * j;
171
            if (k < -100)
172
              link_error ();
173
            if (k > 200)
174
              link_error ();
175
 
176
            return k;
177
          }
178
 
179
  /* [10, 20] * [2, 10] should give [20, 200].  */
180
  if (i >= 10)
181
    if (i <= 20)
182
      if (j >= 2)
183
        if (j <= 10)
184
          {
185
            k = i * j;
186
            if (k < 20)
187
              link_error ();
188
            if (k > 200)
189
              link_error ();
190
 
191
            return k;
192
          }
193
 
194
  /* [10, 20] * [-10, -2] should give [-200, -20].  */
195
  if (i >= 10)
196
    if (i <= 20)
197
      if (j >= -10)
198
        if (j <= -2)
199
          {
200
            k = i * j;
201
            if (k < -200)
202
              link_error ();
203
            if (k > -20)
204
              link_error ();
205
 
206
            return k;
207
          }
208
 
209
  abort ();
210
}
211
 
212
 
213
main()
214
{
215
  if (foo_div (-10, 5) != -2)
216
    abort ();
217
 
218
  if (foo_div (-16, 4) != -4)
219
    abort ();
220
 
221
  if (foo_div (-15, -5) != 3)
222
    abort ();
223
 
224
  if (foo_div (8, 2) != 4)
225
    abort ();
226
 
227
  if (foo_div (10, -2) != -5)
228
    abort ();
229
 
230
  if (foo_div (20, 5) != 4)
231
    abort ();
232
 
233
  if (foo_div (15, -3) != -5)
234
    abort ();
235
 
236
  if (foo_mult (-10, 5) != -50)
237
    abort ();
238
 
239
  if (foo_mult (-16, 4) != -64)
240
    abort ();
241
 
242
  if (foo_mult (-15, -5) != 75)
243
    abort ();
244
 
245
  if (foo_mult (8, 2) != 16)
246
    abort ();
247
 
248
  if (foo_mult (10, -2) != -20)
249
    abort ();
250
 
251
  if (foo_mult (20, 5) != 100)
252
    abort ();
253
 
254
  if (foo_mult (15, -3) != -45)
255
    abort ();
256
 
257
  return 0;
258
}

powered by: WebSVN 2.1.0

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