Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251
WebSVN – tendra.SVN – Diff – /trunk/src/installers/common/construct/check.c – Rev 2 and 7

Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 60... Line 90...
60
 * Revision 1.36  1996/10/01  08:59:19  currie
90
 * Revision 1.36  1996/10/01  08:59:19  currie
61
 * correct chvar exceptions ADA
91
 * correct chvar exceptions ADA
62
 *
92
 *
63
Revision 1.35  1996/06/24 17:26:57  currie
93
Revision 1.35  1996/06/24 17:26:57  currie
64
PIC code with name substitution
94
PIC code with name substitution
65
 
95
 
66
Revision 1.34  1996/06/13 09:24:55  currie
96
Revision 1.34  1996/06/13 09:24:55  currie
67
Bitfield alignments
97
Bitfield alignments
68
 
98
 
69
Revision 1.33  1996/06/05 15:29:48  currie
99
Revision 1.33  1996/06/05 15:29:48  currie
70
parameter alignment in make_cmpd
100
parameter alignment in make_cmpd
Line 93... Line 123...
93
 * Revision 1.25  1995/10/26  10:14:22  currie
123
 * Revision 1.25  1995/10/26  10:14:22  currie
94
 * solve_tag - kill_exp scope reduced
124
 * solve_tag - kill_exp scope reduced
95
 *
125
 *
96
 * Revision 1.24  1995/10/17  12:59:23  currie
126
 * Revision 1.24  1995/10/17  12:59:23  currie
97
 * Power tests + case + diags
127
 * Power tests + case + diags
98
 *
128
 *
99
 * Revision 1.24  1995/10/17  12:59:23  currie
129
 * Revision 1.24  1995/10/17  12:59:23  currie
100
 * Power tests + case + diags
130
 * Power tests + case + diags
101
 *
131
 *
102
 * Revision 1.23  1995/10/13  15:14:58  currie
132
 * Revision 1.23  1995/10/13  15:14:58  currie
103
 * case + long ints on alpha
133
 * case + long ints on alpha
104
 *
134
 *
105
 * Revision 1.22  1995/10/12  15:52:47  currie
135
 * Revision 1.22  1995/10/12  15:52:47  currie
106
 * inlining bug
136
 * inlining bug
107
 *
137
 *
108
 * Revision 1.21  1995/10/11  17:09:56  currie
138
 * Revision 1.21  1995/10/11  17:09:56  currie
109
 * avs errors
139
 * avs errors
110
 *
140
 *
111
 * Revision 1.20  1995/10/06  14:41:53  currie
141
 * Revision 1.20  1995/10/06  14:41:53  currie
112
 * Env-offset alignments + new div with ET
142
 * Env-offset alignments + new div with ET
113
 *
143
 *
114
 * Revision 1.18  1995/10/04  09:17:26  currie
144
 * Revision 1.18  1995/10/04  09:17:26  currie
115
 * CR95_371 + optimise compounds
145
 * CR95_371 + optimise compounds
116
 *
146
 *
117
 * Revision 1.17  1995/10/03  11:44:58  currie
147
 * Revision 1.17  1995/10/03  11:44:58  currie
118
 * field(compound)
148
 * field(compound)
119
 *
149
 *
120
 * Revision 1.16  1995/10/02  10:55:54  currie
150
 * Revision 1.16  1995/10/02  10:55:54  currie
121
 * Alpha varpars + errhandle
151
 * Alpha varpars + errhandle
122
 *
152
 *
123
 * Revision 1.15  1995/09/19  16:06:43  currie
153
 * Revision 1.15  1995/09/19  16:06:43  currie
124
 * isAlpha!!
154
 * isAlpha!!
125
 *
155
 *
126
 * Revision 1.14  1995/09/15  13:29:00  currie
156
 * Revision 1.14  1995/09/15  13:29:00  currie
127
 * hppa + add_prefix + r_w_m complex
157
 * hppa + add_prefix + r_w_m complex
128
 *
158
 *
129
 * Revision 1.13  1995/09/11  15:35:32  currie
159
 * Revision 1.13  1995/09/11  15:35:32  currie
130
 * caller params -ve
160
 * caller params -ve
131
 *
161
 *
132
 * Revision 1.12  1995/08/31  14:18:56  currie
162
 * Revision 1.12  1995/08/31  14:18:56  currie
133
 * mjg mods
163
 * mjg mods
Line 226... Line 256...
226
#include "localflags.h"
256
#include "localflags.h"
227
#endif
257
#endif
228
 
258
 
229
#include "check.h"
259
#include "check.h"
230
 
260
 
231
extern shape containedshape PROTO_S ((int,int));
261
extern shape containedshape(int, int);
232
 
262
 
233
/* MACROS */
263
/* MACROS */
234
 
264
 
235
  /* codes for error treaments */
265
/* codes for error treaments */
236
#define impossible 1
266
#define impossible 1
237
#define ignore 2
267
#define ignore 2
238
 
268
 
239
/* IDENTITIES */
269
/* IDENTITIES */
240
 
270
 
241
static int  masks[33] = {
271
static int masks[33] = {
242
  0,
272
	0,
243
  0x1, 0x3, 0x7, 0xf,
273
	0x1, 0x3, 0x7, 0xf,
244
  0x1f, 0x3f, 0x7f, 0xff,
274
	0x1f, 0x3f, 0x7f, 0xff,
245
  0x1ff, 0x3ff, 0x7ff, 0xfff,
275
	0x1ff, 0x3ff, 0x7ff, 0xfff,
246
  0x1fff, 0x3fff, 0x7fff, 0xffff,
276
	0x1fff, 0x3fff, 0x7fff, 0xffff,
247
  0x1ffff, 0x3ffff, 0x7ffff, 0xfffff,
277
	0x1ffff, 0x3ffff, 0x7ffff, 0xfffff,
248
  0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
278
	0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
249
  0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff,
279
	0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff,
250
  0x1fffffff, 0x3fffffff, 0x7fffffff, (int)0xffffffff
280
	0x1fffffff, 0x3fffffff, 0x7fffffff, (int)0xffffffff
251
};
281
};
252
 
282
 
253
ntest int_inverse_ntest[] = {0, 4, 3, 2, 1, 6, 5};
283
ntest int_inverse_ntest[] = {0, 4, 3, 2, 1, 6, 5};
254
ntest real_inverse_ntest[] = {0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
284
ntest real_inverse_ntest[] = {0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 14, 13};
255
				 12, 11, 14, 13};
-
 
256
ntest exchange_ntest[] = {0, 3, 4, 1, 2, 5, 6, 9, 10, 7, 8, 11, 12, 13,
285
ntest exchange_ntest[] = {0, 3, 4, 1, 2, 5, 6, 9, 10, 7, 8, 11, 12, 13, 14};
257
				 14};
-
 
258
 
286
 
259
#if FBASE == 10
287
#if FBASE == 10
260
static char maxdigs[] = "4294967296";
288
static char maxdigs[] = "4294967296";
261
#endif
289
#endif
262
 
290
 
Line 267... Line 295...
267
  hold_check holds an exp as the son of a dummy exp and then
295
  hold_check holds an exp as the son of a dummy exp and then
268
  applies check. After checking it retcells the dummy exp.
296
  applies check. After checking it retcells the dummy exp.
269
 
297
 
270
 ***********************************************************************/
298
 ***********************************************************************/
271
/* puts body on a hold */
299
/* puts body on a hold */
272
exp hold
300
exp
273
    PROTO_N ( (body) )
-
 
274
    PROTO_T ( exp body )
301
hold(exp body)
275
{
302
{
276
  exp body_hold = next_exp();
303
	exp body_hold = next_exp();
277
  son (body_hold) = body;
304
	son(body_hold) = body;
278
  bro (body) = body_hold;
305
	bro(body) = body_hold;
279
  setlast (body);
306
	setlast(body);
280
  bro (body_hold) = nilexp;
307
	bro(body_hold) = nilexp;
281
 
308
 
282
#if diagnose_registers
309
#if diagnose_registers
283
  setname (body_hold, hold_tag);
310
	setname(body_hold, hold_tag);
284
#else
311
#else
285
  setname (body_hold, 102);
312
	setname(body_hold, 102);
286
#endif
313
#endif
287
 
314
 
288
  return (body_hold);
315
	return(body_hold);
289
}
316
}
290
 
317
 
291
exp hold_check
-
 
292
    PROTO_N ( (r) )
-
 
293
    PROTO_T ( exp r )
-
 
294
{
-
 
295
  exp h, sn;
-
 
296
  h = hold (r);
-
 
297
  IGNORE check (r, r);
-
 
298
  sn = son (h);
-
 
299
  bro(sn) = nilexp;
-
 
300
  retcell (h);
-
 
301
  return (sn);
-
 
302
}
-
 
303
 
-
 
304
exp hold_const_check
-
 
305
    PROTO_N ( (r) )
-
 
306
    PROTO_T ( exp r )
-
 
307
{
-
 
308
  exp ans;
-
 
309
  int old = all_variables_visible;
-
 
310
  all_variables_visible = 0;
-
 
311
  ans = hold_check (r);
-
 
312
  all_variables_visible = old;
-
 
313
  return ans;
-
 
314
}
-
 
315
 
-
 
316
static exp varchange
-
 
317
    PROTO_N ( (s, e) )
-
 
318
    PROTO_T ( shape s X exp e )
-
 
319
{
-
 
320
				/* applies a change_var operation to e, to
-
 
321
				   get shape s */
-
 
322
  exp r = getexp (s, nilexp, 0, e, nilexp, 0, 0,
-
 
323
      chvar_tag);
-
 
324
  setlast(e);
-
 
325
  bro(e) = r;
-
 
326
  return (hold_check (r));
-
 
327
}
-
 
328
 
-
 
329
static int flpt_power_of_2
-
 
330
    PROTO_N ( (f) )
-
 
331
    PROTO_T ( flpt f )
-
 
332
{
-
 
333
  flt * r = &flptnos[f];
-
 
334
  unsigned short us = r -> mant[0];
-
 
335
  int i;
-
 
336
 
-
 
337
  if ((us & (us - 1)) != 0)
-
 
338
    return 0;
-
 
339
  for (i = 1; i < MANT_SIZE; i++) {
-
 
340
    if (r -> mant[i] != 0)
-
 
341
      return 0;
-
 
342
  };
-
 
343
 
318
 
-
 
319
exp
-
 
320
hold_check(exp r)
-
 
321
{
-
 
322
	exp h, sn;
-
 
323
	h = hold(r);
-
 
324
	IGNORE check(r, r);
-
 
325
	sn = son(h);
-
 
326
	bro(sn) = nilexp;
-
 
327
	retcell(h);
-
 
328
	return(sn);
-
 
329
}
-
 
330
 
-
 
331
 
-
 
332
exp
-
 
333
hold_const_check(exp r)
-
 
334
{
-
 
335
	exp ans;
-
 
336
	int old = all_variables_visible;
-
 
337
	all_variables_visible = 0;
-
 
338
	ans = hold_check(r);
-
 
339
	all_variables_visible = old;
-
 
340
	return ans;
-
 
341
}
-
 
342
 
-
 
343
 
-
 
344
static
-
 
345
exp varchange(shape s, exp e)
-
 
346
{
-
 
347
	/* applies a change_var operation to e, to get shape s */
-
 
348
	exp r = getexp(s, nilexp, 0, e, nilexp, 0, 0, chvar_tag);
-
 
349
	setlast(e);
-
 
350
	bro(e) = r;
-
 
351
	return(hold_check(r));
-
 
352
}
-
 
353
 
-
 
354
 
-
 
355
static int
-
 
356
flpt_power_of_2(flpt f)
-
 
357
{
-
 
358
	flt *r = &flptnos[f];
-
 
359
	unsigned short us = r->mant[0];
-
 
360
	int i;
-
 
361
 
-
 
362
	if ((us & (us - 1)) != 0) {
-
 
363
		return 0;
-
 
364
	}
-
 
365
	for (i = 1; i < MANT_SIZE; i++) {
-
 
366
		if (r->mant[i] != 0) {
-
 
367
			return 0;
-
 
368
		}
-
 
369
	}
-
 
370
 
344
  return 1;
371
	return 1;
345
}
372
}
346
 
-
 
347
 
373
 
348
 
374
 
349
/***********************************************************************
375
/***********************************************************************
350
   eq_explist compares two descendant lists of exp for equality.
376
   eq_explist compares two descendant lists of exp for equality.
351
   The given values, their bro's, bro(bro)'s  etc are compared until
377
   The given values, their bro's, bro(bro)'s etc are compared until
352
   an unequal pair is found or the end of one of the  lists (last) is
378
   an unequal pair is found or the end of one of the lists (last) is
353
   found. In this case the lists are equal iff both ends have been
379
   found. In this case the lists are equal iff both ends have been
354
   reached.
380
   reached.
355
 ***********************************************************************/
381
 ***********************************************************************/
356
 
382
 
357
static int eq_explist
383
static int
358
    PROTO_N ( (al, bl) )
-
 
359
    PROTO_T ( exp al X exp bl )
384
eq_explist(exp al, exp bl)
360
{
385
{
361
  if (al == nilexp && bl == nilexp)
386
	if (al == nilexp && bl == nilexp) {
362
    return (1);
387
		return(1);
-
 
388
	}
363
  if (al == nilexp || bl == nilexp)
389
	if (al == nilexp || bl == nilexp) {
364
    return (0);
390
		return(0);
-
 
391
	}
365
  if (!eq_exp (al, bl))
392
	if (!eq_exp(al, bl)) {
366
    return (0);
393
		return(0);
-
 
394
	}
367
  if (last (al) && last (bl))
395
	if (last(al) && last(bl)) {
368
    return (1);
396
		return(1);
-
 
397
	}
369
  if (last (al) || last (bl))
398
	if (last(al) || last(bl)) {
370
    return (0);
399
		return(0);
-
 
400
	}
371
  return (eq_explist (bro (al), bro (bl)));
401
	return(eq_explist(bro(al), bro(bl)));
372
}
402
}
-
 
403
 
373
 
404
 
374
/***********************************************************************
405
/***********************************************************************
375
    eq_exp compares two exp for equality of effect. If the name of either
406
    eq_exp compares two exp for equality of effect. If the name of either
376
    exp is in the side-effecting group (!is_a) the exp are not equal.
407
    exp is in the side-effecting group (!is_a) the exp are not equal.
377
    This is a crude test, but if it says the exps are equal this is so.
408
    This is a crude test, but if it says the exps are equal this is so.
378
    contvol is forbidden.
409
    contvol is forbidden.
379
 ***********************************************************************/
410
 ***********************************************************************/
380
 
411
 
381
int eq_exp
412
int
-
 
413
eq_exp(exp a, exp b)
-
 
414
{
382
    PROTO_N ( (a, b) )
415
	if (name(a) == name(b)) {
-
 
416
		if (name(a) == name_tag) {
-
 
417
			return(son(a) == son(b) && no(a) == no(b) &&
383
    PROTO_T ( exp a X exp b )
418
			       eq_shape(sh(a), sh(b)));
-
 
419
		}
-
 
420
		if (!is_a(name(a)) || !eq_shape(sh(a), sh(b)) ||
-
 
421
		    name(a) == contvol_tag) {
-
 
422
			return(0);
-
 
423
		}
-
 
424
		if (name(a) == real_tag) {
-
 
425
			int res = flt_cmp(flptnos[no(a)], flptnos[no(b)]);
-
 
426
			return(res == 0);
-
 
427
		}
-
 
428
		if (name(a) == val_tag) {
-
 
429
			if (isbigval(a)) {
-
 
430
				int res;
-
 
431
				if (!isbigval(b)) {
-
 
432
					return 0;
-
 
433
				}
-
 
434
				res = flt_cmp(flptnos[no(a)], flptnos[no(b)]);
-
 
435
				return(res == 0);
-
 
436
			}
-
 
437
			if (isbigval(b)) {
-
 
438
				return 0;
-
 
439
			}
-
 
440
			return(no(a) == no(b));
-
 
441
		}
-
 
442
		return(no(a) == no(b) && eq_explist(son(a), son(b)));
-
 
443
	}
-
 
444
	return(0);
-
 
445
}
-
 
446
 
-
 
447
 
-
 
448
/**********************************************************************
-
 
449
   repbycont replaces e by the exp which loads top, ie. does nothing.
-
 
450
 **********************************************************************/
-
 
451
 
-
 
452
static void
-
 
453
repbycont(exp e, bool has_label, exp scope)
384
{
454
{
385
  if (name (a) == name (b)) {
-
 
386
    if (name (a) == name_tag)
-
 
387
      return (son (a) == son (b) && no (a) == no (b) &&
455
	exp n = getexp(f_top, bro(e), (int)(last(e)), nilexp, nilexp, 0, 0,
388
	  eq_shape (sh (a), sh (b)));
-
 
389
    if (!is_a (name (a)) || !eq_shape (sh (a), sh (b)) ||
-
 
390
		 name(a) == contvol_tag)
456
		       top_tag);
391
      return (0);
457
	if (has_label) {
392
    if (name (a) == real_tag) {
458
		no(son(pt(e)))--;
393
      int   res = flt_cmp (flptnos[no (a)], flptnos[no (b)]);
-
 
394
      return (res == 0);
459
		pt(e) = nilexp;
395
    };
460
	}
396
    if (name(a) == val_tag)  {
-
 
397
      if (isbigval(a)) {
-
 
398
	int res;
461
#ifdef NEWDIAGS
399
	if (!isbigval(b))
462
	dgf(n) = dgf(e);
400
	  return 0;
463
#endif
401
	res = flt_cmp (flptnos[no (a)], flptnos[no (b)]);
-
 
402
        return (res == 0);
464
	replace(e, n, e);
403
      };
-
 
404
      if (isbigval(b))
-
 
405
	return 0;
465
	kill_exp(e, e);
406
      return (no(a) == no(b));
-
 
407
    };
-
 
408
    return (no (a) == no (b) &&
466
	if (scope !=e) {
409
	eq_explist (son (a), son (b)));
467
		altered(n, scope);
410
  };
468
	}
411
  return (0);
-
 
412
}
469
}
413
 
470
 
414
 
471
 
415
/**********************************************************************
472
/**********************************************************************
416
   repbycont replaces e by the exp which loads top, ie. does nothing.
473
   repbygo replaces e by a goto the label.
417
 **********************************************************************/
474
 **********************************************************************/
418
 
475
 
419
static void repbycont
476
static void
420
    PROTO_N ( (e, has_label, scope) )
-
 
421
    PROTO_T ( exp e X bool has_label X exp scope )
477
repbygo(exp e, exp lab, exp scope)
422
{
478
{
423
  exp n = getexp (f_top, bro (e), (int)(last (e)), nilexp, nilexp, 0, 0, top_tag);
479
	exp g = getexp(f_bottom, nilexp, 0, nilexp, lab, 0, 0, goto_tag);
424
  if (has_label) {
480
	exp n = getexp(f_top, g, 1, nilexp, nilexp, 0, 0, top_tag);
425
    no (son (pt (e)))--;
481
	son(g) = n;
426
    pt (e) = nilexp;
482
	++no(son(lab));
427
  };
-
 
428
#ifdef NEWDIAGS
483
#ifdef NEWDIAGS
429
  dgf(n) = dgf(e);
484
	dgf(g) = dgf(e);
430
#endif
485
#endif
431
  replace (e, n, e);
486
	replace(e, g, e);
432
  kill_exp (e, e);
487
	kill_exp(e, e);
-
 
488
	if (scope !=e) {
433
  if (scope !=e) altered(n,scope);
489
		altered(g, scope);
-
 
490
	}
434
}
491
}
-
 
492
 
435
 
493
 
436
/**********************************************************************
494
/**********************************************************************
437
   repbygo replaces e by a goto the label.
495
   nos tests the exp t to see if it is a construction that can be
-
 
496
   eliminated from a sequence.  It is ignorable or has no side effect.
438
 **********************************************************************/
497
 **********************************************************************/
-
 
498
static int nos(exp t);
439
 
499
 
440
static void repbygo
500
static int
441
    PROTO_N ( (e, lab, scope) )
501
noslist(exp tl)
442
    PROTO_T ( exp e X exp lab X exp scope )
-
 
443
{
502
{
444
  exp g = getexp (f_bottom, nilexp, 0, nilexp, lab, 0, 0, goto_tag);
-
 
445
  exp n = getexp (f_top, g, 1, nilexp, nilexp, 0, 0, top_tag);
-
 
446
  son (g) = n;
-
 
447
  ++no (son (lab));
503
	if (tl == nilexp) {
448
#ifdef NEWDIAGS
-
 
449
  dgf(g) = dgf(e);
504
		return(1);
450
#endif
505
	}
451
  replace (e, g, e);
506
	if (last(tl)) {
452
  kill_exp (e, e);
507
		return(nos(tl));
-
 
508
	}
453
  if (scope !=e) altered(g,scope);
509
	return(nos(tl) && noslist(bro(tl)));
454
}
510
}
455
 
511
 
456
/**********************************************************************
-
 
457
   nos tests the exp t to see if it is a construction that can be
-
 
458
   eliminated from a sequence.  It is ignorable or has no side effect.
-
 
459
 **********************************************************************/
-
 
460
static int nos PROTO_S ((exp t));
-
 
461
 
512
 
462
static int noslist
513
static int
463
    PROTO_N ( (tl) )
-
 
464
    PROTO_T ( exp tl )
514
nos(exp t)
465
{
515
{
466
  if (tl == nilexp)
516
	unsigned char n = name(t);
467
    return (1);
-
 
468
  if (last (tl))
517
	if (n == top_tag || n == ignorable_tag) {
469
    return (nos (tl));
518
		return(1);
470
  return (nos (tl) && noslist (bro (tl)));
-
 
471
}
519
	}
472
 
-
 
473
 
-
 
474
static int nos
-
 
475
    PROTO_N ( (t) )
520
	if (n == compound_tag || n == nof_tag) {
476
    PROTO_T ( exp t )
521
		return noslist(son(t));
477
{
522
	}
478
  unsigned char n = name(t);
-
 
479
  if (n == top_tag || n == ignorable_tag)
-
 
480
    return (1);
-
 
481
  if (n == compound_tag || n == nof_tag) return noslist(son(t));
-
 
482
 
523
 
483
  return (	(is_a (n) &&
524
	return((is_a(n) && optop(t) &&
484
		 optop(t) &&
-
 
485
		 ((n == name_tag && !islastuse(t)) ||
525
		((n == name_tag && !islastuse(t)) || n == val_tag ||
486
		  n == val_tag ||
-
 
487
		  noslist (son (t))
-
 
488
		 )
-
 
489
		) ||
-
 
490
           	(n == ident_tag && !isenvoff(t) &&
526
		 noslist(son(t)))) || (n == ident_tag && !isenvoff(t) &&
491
		 nos (son (t)) &&
-
 
492
	     	 nos (bro (son (t)))
527
				       nos(son(t)) && nos(bro(son(t)))));
493
		)
-
 
494
	 );
-
 
495
}
528
}
496
 
529
 
497
 
-
 
498
 
530
 
499
/**********************************************************************
531
/**********************************************************************
500
   check_seq carries out transformations on sequences.
532
   check_seq carries out transformations on sequences.
501
   Statements with no effect are removed.
533
   Statements with no effect are removed.
502
   Anything after an unconditional goto, or any other statement
534
   Anything after an unconditional goto, or any other statement
503
   producing a bottom shape, is removed.
535
   producing a bottom shape, is removed.
504
 
536
 
505
   No changes are propagated outside the exp "scope".
537
   No changes are propagated outside the exp "scope".
506
 **********************************************************************/
538
 **********************************************************************/
507
static int maxes [] = {0, 0, 0, 127, 255, 32767, 65535,
539
static int maxes[] = {0, 0, 0, 127, 255, 32767, 65535, (int)0x7fffffff,
508
		 (int)0x7fffffff, (int)0xffffffff};
540
	(int)0xffffffff};
509
static int mins[] = {0, 0, 0, -128, 0, -32768, 0, (int)0xffffffff, 0};
541
static int mins[] = {0, 0, 0, -128, 0, -32768, 0, (int)0xffffffff, 0};
809
 
864
 
810
/**********************************************************************
865
/**********************************************************************
811
 
866
 
812
   comm_ass applies the commutative and associative laws to replace e
867
   comm_ass applies the commutative and associative laws to replace e
813
   by an improved version. op_tag is the operation involved. If
868
   by an improved version. op_tag is the operation involved. If
Line 833... Line 888...
833
   (integer or real) and delivers an exp defining a constant which is
888
   (integer or real) and delivers an exp defining a constant which is
834
   the result of the op_tag applied to these constants.
889
   the result of the op_tag applied to these constants.
835
 
890
 
836
 
891
 
837
 **********************************************************************/
892
 **********************************************************************/
838
static int  f_one PROTO_S ((flpt f));
893
static int f_one(flpt f);
839
static int seq_distr PROTO_S ((exp e, exp scope));
894
static int seq_distr(exp e, exp scope);
840
 
-
 
841
static int comm_ass
-
 
842
    PROTO_N ( (e, op_tag, fn, one, has_zero, zero, scope, dive, isreal) )
-
 
843
    PROTO_T ( exp e X unsigned char op_tag X
-
 
844
	      void  (*fn) PROTO_S (( exp, exp, int )) X
-
 
845
	      int one X int has_zero X int zero X exp scope X
-
 
846
	      int dive X int isreal )
-
 
847
{
-
 
848
  exp t = son (e);		/* starting element */
-
 
849
  int changed = last (t);
-
 
850
  exp  cst;		/* start the accumulated constant */
-
 
851
  exp cst_u = nilexp;	/* holds exp representing one if created here */
-
 
852
  int looping;
-
 
853
 
-
 
854
  if (isreal)
-
 
855
     cst = getexp (sh (e), nilexp, 0, nilexp, nilexp, 0, one, real_tag);
-
 
856
  else  {
-
 
857
     cst = me_shint(sh(e), one);
-
 
858
     if (one == -1 && shape_size(sh(e)) == 64) {
-
 
859
	flpt f = new_flpt();
-
 
860
	flt * fp = &flptnos[f];
-
 
861
	int i;
-
 
862
	fp->sign = 1;
-
 
863
	fp->exp = 3;
-
 
864
	for (i=0; i< 4; ++i)
-
 
865
	  fp->mant[i] = 65535;
-
 
866
	no(cst) = f;
-
 
867
	setbigval(cst);
-
 
868
        cst_u = cst;
-
 
869
     };
-
 
870
  };
-
 
871
 
895
 
-
 
896
static int
-
 
897
comm_ass(exp e, unsigned char op_tag, void (*fn)(exp, exp, int), int one,
-
 
898
	 int has_zero, int zero, exp scope, int dive, int isreal)
-
 
899
{
-
 
900
	exp t = son(e);	/* starting element */
-
 
901
	int changed = last(t);
-
 
902
	exp cst;		/* start the accumulated constant */
-
 
903
	exp cst_u = nilexp;	/* holds exp representing one if created here */
-
 
904
	int looping;
-
 
905
 
-
 
906
	if (isreal) {
-
 
907
		cst = getexp(sh(e), nilexp, 0, nilexp, nilexp, 0, one,
-
 
908
			     real_tag);
-
 
909
	} else {
-
 
910
		cst = me_shint(sh(e), one);
-
 
911
		if (one == -1 && shape_size(sh(e)) == 64) {
-
 
912
			flpt f = new_flpt();
-
 
913
			flt *fp = &flptnos[f];
-
 
914
			int i;
-
 
915
			fp->sign = 1;
-
 
916
			fp->exp = 3;
-
 
917
			for (i = 0; i < 4; ++i) {
-
 
918
				fp->mant[i] = 65535;
-
 
919
			}
-
 
920
			no(cst) = f;
-
 
921
			setbigval(cst);
-
 
922
			cst_u = cst;
-
 
923
		}
-
 
924
	}
-
 
925
 
872
  if (!optop(e))
926
	if (!optop(e)) {
873
    return 0;
927
		return 0;
-
 
928
	}
-
 
929
	do {
874
  do {				/* look to see if a change will be made */
930
		/* look to see if a change will be made */
875
    if ((name (t) == op_tag && optop(t)) || name (t) == val_tag ||
931
		if ((name(t) == op_tag && optop(t)) || name(t) == val_tag ||
876
           name(t) == real_tag)
932
		    name(t) == real_tag) {
877
      changed = 1;
933
			changed = 1;
-
 
934
		}
878
    looping = !last (t);
935
		looping = !last(t);
879
    t = bro (t);
936
		t = bro(t);
880
  }
-
 
881
  while (looping);
937
	} while (looping);
882
 
938
 
-
 
939
	if (changed) {
883
  if (changed) {		/* continue if there will be a change */
940
		/* continue if there will be a change */
884
    exp p, q;
941
		exp p, q;
885
    t = son (e);		/* start */
942
		t = son(e);	/* start */
886
    q = getexp (sh (e), nilexp, 0, nilexp, nilexp, 0, 0, op_tag);
943
		q = getexp(sh(e), nilexp, 0, nilexp, nilexp, 0, 0, op_tag);
887
    seterrhandle(q, errhandle(e));
944
		seterrhandle(q, errhandle(e));
888
    /* start the result */
945
		/* start the result */
-
 
946
		p = q;
889
    p = q;			/* p is used to point to the current place
947
		/* p is used to point to the current place where the next item
890
				   where the next item will be added (as
-
 
891
				   bro). */
948
		 * will be added (as bro). */
892
    do {
949
		do {
893
      while (name (t) == op_tag && optop(t) && dive)
950
			while (name(t) == op_tag && optop(t) && dive) {
894
	t = son (t);		/* dive down same operator */
951
				t = son(t);	/* dive down same operator */
-
 
952
			}
895
      if (name (t) == val_tag || name(t) == real_tag) {
953
			if (name(t) == val_tag || name(t) == real_tag) {
896
	fn (cst, t, errhandle(e));	/* accumulate constant value */
954
				/* accumulate constant value */
-
 
955
				fn (cst, t, errhandle(e));
897
#ifdef NEWDIAGS
956
#ifdef NEWDIAGS
898
	if (diagnose)
957
				if (diagnose) {
899
	  dg_detach_const (t, cst);
958
					dg_detach_const(t, cst);
-
 
959
				}
900
#endif
960
#endif
901
      }
961
			} else {
902
      else {			/* add item at p and move p on */
962
				/* add item at p and move p on */
903
	bro (p) = t;
963
				bro(p) = t;
904
	clearlast (p);
964
				clearlast(p);
905
	p = bro (p);
965
				p = bro(p);
906
      };
966
			}
907
      while (last (t) && bro (t) != e)
967
			while (last(t) && bro(t) != e) {
908
	t = bro (t);		/* ascend from sub-item */
968
				/* ascend from sub-item */
-
 
969
				t = bro(t);
909
    }
970
			}
910
    while ((last (t)) ? 0 : (t = bro (t), 1));
971
		} while ((last(t)) ? 0 : (t = bro(t), 1));
911
    son (q) = bro (q);		/* put q into correct form (we were using
972
		/* put q into correct form (we were using its bro) */
912
				   its bro) */
973
		son(q) = bro(q);
913
 
974
 
914
    if (p == q) {
975
		if (p == q) {
915
      /* no items but constant */
976
			/* no items but constant */
916
      retcell(q);
977
			retcell(q);
917
#ifdef NEWDIAGS
978
#ifdef NEWDIAGS
918
      if (diagnose)
979
			if (diagnose) {
919
	dg_whole_comp (e, cst);
980
				dg_whole_comp(e, cst);
-
 
981
			}
920
#endif
982
#endif
921
      replace (e, cst, scope);
983
			replace(e, cst, scope);
922
      retcell(e);
984
			retcell(e);
923
      return (1);
985
			return(1);
924
    };
986
		}
925
 
987
 
926
    if (has_zero &&
988
		if (has_zero &&
927
         ((!isreal && no(cst) == zero && !isbigval(cst)) ||
989
		    ((!isreal && no(cst) == zero && !isbigval(cst)) ||
928
          (isreal && flptnos[no(cst)].sign == 0))) {
990
		     (isreal && flptnos[no(cst)].sign == 0))) {
929
      /* zero constant. Replace by a sequence of expressions delivering
991
			/* zero constant. Replace by a sequence of expressions
930
         the zero, so as to keep side effects */
992
			 * delivering the zero, so as to keep side effects */
931
      exp r;
993
			exp r;
932
      setname (q, 0);		/* use q a seq holder */
994
			setname(q, 0);		/* use q a seq holder */
933
      son (q) = bro (q);
995
			son(q) = bro(q);
934
      bro (p) = q;
996
			bro(p) = q;
935
      setlast (p);
997
			setlast(p);
936
      clearlast (q);
998
			clearlast(q);
937
      bro (q) = cst;
999
			bro(q) = cst;
938
      r = getexp (sh (e), nilexp, 0, q, nilexp, 0, 0, seq_tag);
1000
			r = getexp(sh(e), nilexp, 0, q, nilexp, 0, 0, seq_tag);
-
 
1001
#ifdef NEWDIAGS
-
 
1002
			if (diagnose) {
-
 
1003
				dgf(r) = dgf(e);
-
 
1004
			}
-
 
1005
#endif
-
 
1006
			replace(e, hc(r, cst), scope);
-
 
1007
			return(1);
-
 
1008
		}
-
 
1009
 
-
 
1010
		if ((!isreal &&
-
 
1011
		     (no(cst) != one || (isbigval(cst) && cst != cst_u))) ||
-
 
1012
		    (isreal && cmpflpt(no(cst), one, 6))) {
-
 
1013
			/* form result if there is a non-unit constant term */
-
 
1014
			bro(p) = cst;
-
 
1015
			clearlast(p);
-
 
1016
			p = bro(p);
-
 
1017
			son(q) = bro(q);
-
 
1018
			bro(p) = q;
-
 
1019
			setlast(p);
-
 
1020
			sh(q) = sh(e);
939
#ifdef NEWDIAGS
1021
#ifdef NEWDIAGS
940
      if (diagnose)
1022
			if (diagnose) {
941
	dgf(r) = dgf(e);
1023
				dgf(q) = dgf(e);
-
 
1024
			}
942
#endif
1025
#endif
943
      replace (e, hc (r, cst), scope);
1026
			replace(e, q, scope);
-
 
1027
			retcell(e);
944
      return (1);
1028
			return(1);
945
    };
1029
		}
946
 
1030
 
947
    if ((!isreal &&
-
 
948
		(no(cst) != one || (isbigval(cst) && cst != cst_u))) ||
-
 
949
         (isreal && cmpflpt(no(cst), one, 6))) {
-
 
950
		/* form result if there is a non-unit
-
 
951
				   constant term */
-
 
952
      bro (p) = cst;
-
 
953
      clearlast (p);
-
 
954
      p = bro (p);
-
 
955
      son (q) = bro (q);
-
 
956
      bro (p) = q;
-
 
957
      setlast (p);
-
 
958
      sh (q) = sh (e);
-
 
959
#ifdef NEWDIAGS
1031
#ifdef NEWDIAGS
960
      if (diagnose)
1032
		if (diagnose) {
961
	dgf(q) = dgf(e);
1033
			dgf(e) = combine_diaginfo(dgf(e), dgf(cst));
-
 
1034
		}
962
#endif
1035
#endif
963
      replace (e, q, scope);
1036
		retcell(cst);   /* there are no constants other than unit*/
964
      retcell(e);
-
 
965
      return (1);
-
 
966
    };
-
 
967
 
1037
 
-
 
1038
		if (son(q) == p) {
-
 
1039
			/* form result if single item and no constant */
-
 
1040
			sh(p) = sh(e);
968
#ifdef NEWDIAGS
1041
#ifdef NEWDIAGS
969
    if (diagnose)
1042
			if (diagnose) {
970
      dgf(e) = combine_diaginfo (dgf(e), dgf(cst));
1043
				dg_whole_comp(e, p);
-
 
1044
			}
971
#endif
1045
#endif
972
    retcell(cst);   /* there are no constants other than unit*/
-
 
973
 
-
 
974
    if (son (q) == p) {		/* form result if single item and no
-
 
975
				   constant */
-
 
976
      sh (p) = sh (e);
-
 
977
#ifdef NEWDIAGS
-
 
978
      if (diagnose)
-
 
979
	dg_whole_comp (e, p);
-
 
980
#endif
-
 
981
      replace (e, hold_check(p), scope);
1046
			replace(e, hold_check(p), scope);
982
      retcell(e);
1047
			retcell(e);
983
      return (1);
1048
			return(1);
984
    };
1049
		}
985
 
1050
 
986
    bro (p) = q;		/* form result if no constant and more
1051
		/* form result if no constant and more than one arg */
987
				   than one arg */
1052
		bro(p) = q;
-
 
1053
 
988
    setlast (p);
1054
		setlast(p);
989
    sh (q) = sh (e);
1055
		sh(q) = sh(e);
990
#ifdef NEWDIAGS
1056
#ifdef NEWDIAGS
991
    if (diagnose)
1057
		if (diagnose) {
992
      dg_whole_comp (e, q);
1058
			dg_whole_comp(e, q);
-
 
1059
		}
993
#endif
1060
#endif
1131
 
1193
 
1132
/* used as a fn parameter for comm_ass q.v. */
1194
/* used as a fn parameter for comm_ass q.v. */
1133
static void fmult_fn
-
 
1134
    PROTO_N ( (ap, b, et) )
-
 
1135
    PROTO_T ( exp ap X exp b X int et )
-
 
1136
{
-
 
1137
  int a = no(ap);
-
 
1138
  int  nob = no (b);
-
 
1139
  flt resval;
-
 
1140
  int status;
-
 
1141
  UNUSED (et);
-
 
1142
 
1195
 
1143
  status = flt_mul (flptnos[a], flptnos[nob], &resval);
-
 
1144
  if (status == OKAY) {
1196
static void
1145
      flpt_round((int)f_to_nearest,
1197
fmult_fn(exp ap, exp b, int et)
1146
		 flpt_bits((floating_variety)(name(sh(b))-shrealhd)),
-
 
-
 
1198
{
1147
		 &resval);
1199
	int a = no(ap);
1148
      flptnos[nob] = resval;
-
 
1149
      no(ap) = nob;
1200
	int nob = no(b);
1150
    }
1201
	flt resval;
1151
  else
1202
	int status;
1152
    failer(ILLEGAL_FLMULT);
-
 
1153
  return;
1203
	UNUSED(et);
1154
}
-
 
1155
 
1204
 
-
 
1205
	status = flt_mul(flptnos[a], flptnos[nob], &resval);
-
 
1206
	if (status == OKAY) {
-
 
1207
		flpt_round((int)f_to_nearest,
-
 
1208
			   flpt_bits((floating_variety)(name(sh(b)) -
-
 
1209
							shrealhd)), &resval);
-
 
1210
		flptnos[nob] = resval;
-
 
1211
		no(ap) = nob;
-
 
1212
	} else {
-
 
1213
		failer(ILLEGAL_FLMULT);
-
 
1214
	}
-
 
1215
	return;
-
 
1216
}
1156
 
1217
 
1157
 
1218
 
1158
/* auxiliary function used for comm_ass by plus */
1219
/* auxiliary function used for comm_ass by plus */
1159
static void plus_fn
-
 
1160
    PROTO_N ( (ap, b, et) )
-
 
1161
    PROTO_T ( exp ap X exp b X int et )
-
 
1162
{
-
 
1163
  flt64 x;
-
 
1164
  flpt fa, fb;
-
 
1165
  int sg = is_signed(sh(ap));
-
 
1166
  flt resval;
-
 
1167
  int ov;
-
 
1168
 
-
 
1169
  fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1170
  fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1171
  IGNORE flt_add (flptnos[fa], flptnos[fb], &resval);
-
 
1172
		/* status cannot be wrong */
-
 
1173
  flptnos[fa] = resval;
-
 
1174
  x = flt_to_f64(fa, sg, &ov);
-
 
1175
 
-
 
1176
  if (et != f_wrap.err_code &&
-
 
1177
	(ov || constovf(b) || check_size(x, sg, shape_size(sh(ap)))))
-
 
1178
    setconstovf(ap);
-
 
1179
 
-
 
1180
/*  if (extra_checks && sg && !in_proc_def &&
-
 
1181
	(ov || (shape_size(sh(ap)) <= 32 && check_size(x, sg, 32)))) {
-
 
1182
    failer(ADD_OUT_OF_BOUNDS);
-
 
1183
    exit(EXIT_FAILURE);
-
 
1184
  };
-
 
1185
*/
-
 
1186
  flpt_ret(fa);
-
 
1187
  flpt_ret(fb);
-
 
1188
 
-
 
1189
  bigres(ap, &x);
-
 
1190
  return;
-
 
1191
}
-
 
1192
 
-
 
1193
/* subtract constant from constant */
-
 
1194
static void minus_fn
-
 
1195
    PROTO_N ( (ap, b, et) )
-
 
1196
    PROTO_T ( exp ap X exp b X int et )
-
 
1197
{
-
 
1198
  flt64 x;
-
 
1199
  flpt fa, fb;
-
 
1200
  int sg = is_signed(sh(ap));
-
 
1201
  flt resval;
-
 
1202
  int ov;
-
 
1203
 
-
 
1204
  fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1205
  fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1206
  IGNORE flt_sub (flptnos[fa], flptnos[fb], &resval);
-
 
1207
		/* status cannot be wrong */
-
 
1208
  flptnos[fa] = resval;
-
 
1209
  x = flt_to_f64(fa, sg, &ov);
-
 
1210
 
-
 
1211
  if (et != f_wrap.err_code &&
-
 
1212
	(ov || constovf(b) || check_size(x, sg, shape_size(sh(ap)))))
-
 
1213
    setconstovf(ap);
-
 
1214
 
-
 
1215
/*  if (extra_checks && sg && !in_proc_def &&
-
 
1216
	(ov || (shape_size(sh(ap)) <= 32 && check_size(x, sg, 32)))) {
-
 
1217
    failer(ADD_OUT_OF_BOUNDS);
-
 
1218
    exit(EXIT_FAILURE);
-
 
1219
  };
-
 
1220
*/
-
 
1221
  flpt_ret(fa);
-
 
1222
  flpt_ret(fb);
-
 
1223
 
-
 
1224
  bigres(ap, &x);
-
 
1225
  return;
-
 
1226
}
-
 
1227
 
1220
 
-
 
1221
static void
-
 
1222
plus_fn(exp ap, exp b, int et)
-
 
1223
{
-
 
1224
	flt64 x;
-
 
1225
	flpt fa, fb;
-
 
1226
	int sg = is_signed(sh(ap));
-
 
1227
	flt resval;
-
 
1228
	int ov;
-
 
1229
 
-
 
1230
	fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1231
	fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1232
	IGNORE flt_add(flptnos[fa], flptnos[fb], &resval);
-
 
1233
	/* status cannot be wrong */
-
 
1234
	flptnos[fa] = resval;
-
 
1235
	x = flt_to_f64(fa, sg, &ov);
-
 
1236
 
-
 
1237
	if (et != f_wrap.err_code &&
-
 
1238
	    (ov || constovf(b) || check_size(x, sg, shape_size(sh(ap))))) {
-
 
1239
		setconstovf(ap);
-
 
1240
	}
-
 
1241
 
-
 
1242
	/* if (extra_checks && sg && !in_proc_def &&
-
 
1243
	    (ov || (shape_size(sh(ap)) <= 32 && check_size(x, sg, 32)))) {
-
 
1244
	    failer(ADD_OUT_OF_BOUNDS);
-
 
1245
	    exit(EXIT_FAILURE);
-
 
1246
	    };
-
 
1247
	 */
-
 
1248
	flpt_ret(fa);
-
 
1249
	flpt_ret(fb);
-
 
1250
 
-
 
1251
	bigres(ap, &x);
-
 
1252
	return;
-
 
1253
}
-
 
1254
 
-
 
1255
 
1228
/* negate a constant exp, b, producing int */
1256
/* subtract constant from constant */
-
 
1257
 
1229
static void  neg_fn
1258
static void
-
 
1259
minus_fn(exp ap, exp b, int et)
-
 
1260
{
-
 
1261
	flt64 x;
-
 
1262
	flpt fa, fb;
-
 
1263
	int sg = is_signed(sh(ap));
-
 
1264
	flt resval;
-
 
1265
	int ov;
-
 
1266
 
-
 
1267
	fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1268
	fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1269
	IGNORE flt_sub(flptnos[fa], flptnos[fb], &resval);
-
 
1270
	/* status cannot be wrong */
-
 
1271
	flptnos[fa] = resval;
-
 
1272
	x = flt_to_f64(fa, sg, &ov);
-
 
1273
 
-
 
1274
	if (et != f_wrap.err_code &&
-
 
1275
	    (ov || constovf(b) || check_size(x, sg, shape_size(sh(ap))))) {
-
 
1276
		setconstovf(ap);
-
 
1277
	}
-
 
1278
 
-
 
1279
	/* if (extra_checks && sg && !in_proc_def &&
-
 
1280
	    (ov || (shape_size(sh(ap)) <= 32 && check_size(x, sg, 32)))) {
-
 
1281
	    failer(ADD_OUT_OF_BOUNDS);
1230
    PROTO_N ( (b) )
1282
	    exit(EXIT_FAILURE);
-
 
1283
	    };
-
 
1284
	 */
-
 
1285
	flpt_ret(fa);
-
 
1286
	flpt_ret(fb);
-
 
1287
 
-
 
1288
	bigres(ap, &x);
-
 
1289
	return;
-
 
1290
}
-
 
1291
 
-
 
1292
 
-
 
1293
/* negate a constant exp, b, producing int */
-
 
1294
 
-
 
1295
static void
1231
    PROTO_T ( exp b )
1296
neg_fn(exp b)
1232
{
1297
{
1233
  flt64 x;
1298
	flt64 x;
1234
  x = exp_to_f64(b);
1299
	x = exp_to_f64(b);
1235
  x.big = ~x.big;
1300
	x.big = ~x.big;
1236
  x.small = ~x.small;
1301
	x.small = ~x.small;
1237
  if (x.small == (unsigned int)0xffffffff) {
1302
	if (x.small == (unsigned int)0xffffffff) {
1238
    ++x.big;
1303
		++x.big;
1239
  };
1304
	}
1240
  ++x.small;
1305
	++x.small;
-
 
1306
	bigres(b, &x);
-
 
1307
	return;
-
 
1308
}
-
 
1309
 
-
 
1310
 
-
 
1311
/* negate a constant exp, b, producing int */
-
 
1312
 
-
 
1313
static void
-
 
1314
not_fn(exp b)
-
 
1315
{
-
 
1316
	flt64 x;
-
 
1317
	x = exp_to_f64(b);
-
 
1318
	x.big = ~x.big;
-
 
1319
	x.small = ~x.small;
1241
  bigres(b, &x);
1320
	bigres(b, &x);
1242
  return;
1321
	return;
1243
}
1322
}
1244
 
1323
 
1245
/* negate a constant exp, b, producing int */
-
 
1246
static void  not_fn
-
 
1247
    PROTO_N ( (b) )
-
 
1248
    PROTO_T ( exp b )
-
 
1249
{
-
 
1250
  flt64 x;
-
 
1251
  x = exp_to_f64(b);
-
 
1252
  x.big = ~x.big;
-
 
1253
  x.small = ~x.small;
-
 
1254
  bigres(b, &x);
-
 
1255
  return;
-
 
1256
}
-
 
1257
 
1324
 
1258
/* auxiliary function used for comm_ass by mult */
1325
/* auxiliary function used for comm_ass by mult */
1259
static void mult_fn
-
 
1260
    PROTO_N ( (ap, b, et) )
-
 
1261
    PROTO_T ( exp ap X exp b X int et )
-
 
1262
{
-
 
1263
  flt64 x;
-
 
1264
  flpt fa, fb;
-
 
1265
  int sg = is_signed(sh(ap));
-
 
1266
  flt resval;
-
 
1267
  int ov;
-
 
1268
 
-
 
1269
  fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1270
  fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1271
  IGNORE flt_mul (flptnos[fa], flptnos[fb], &resval);
-
 
1272
		/* status cannot be wrong */
-
 
1273
  flptnos[fa] = resval;
-
 
1274
  x = flt_to_f64(fa, sg, &ov);
-
 
1275
 
-
 
1276
  if (et != f_wrap.err_code &&
-
 
1277
	(ov || constovf(b) || check_size(x, sg, shape_size(sh(ap)))))
-
 
1278
    setconstovf(ap);
-
 
1279
 
-
 
1280
  if (sg && extra_checks &&
-
 
1281
	(ov || (shape_size(sh(ap)) <= 32 && check_size(x, sg, 32)))) {
-
 
1282
    failer(MULT_OUT_OF_BOUNDS);
-
 
1283
    exit(EXIT_FAILURE);
-
 
1284
  };
-
 
1285
 
1326
 
-
 
1327
static void
-
 
1328
mult_fn(exp ap, exp b, int et)
-
 
1329
{
-
 
1330
	flt64 x;
-
 
1331
	flpt fa, fb;
-
 
1332
	int sg = is_signed(sh(ap));
-
 
1333
	flt resval;
-
 
1334
	int ov;
-
 
1335
 
-
 
1336
	fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1337
	fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1338
	IGNORE flt_mul(flptnos[fa], flptnos[fb], &resval);
-
 
1339
	/* status cannot be wrong */
-
 
1340
	flptnos[fa] = resval;
-
 
1341
	x = flt_to_f64(fa, sg, &ov);
-
 
1342
 
-
 
1343
	if (et != f_wrap.err_code &&
-
 
1344
	    (ov || constovf(b) || check_size(x, sg, shape_size(sh(ap))))) {
-
 
1345
		setconstovf(ap);
-
 
1346
	}
-
 
1347
 
-
 
1348
	if (sg && extra_checks &&
-
 
1349
	    (ov || (shape_size(sh(ap)) <= 32 && check_size(x, sg, 32)))) {
-
 
1350
		failer(MULT_OUT_OF_BOUNDS);
-
 
1351
		exit(EXIT_FAILURE);
-
 
1352
	}
-
 
1353
 
1286
  flpt_ret(fa);
1354
	flpt_ret(fa);
1287
  flpt_ret(fb);
1355
	flpt_ret(fb);
1288
 
1356
 
1289
  bigres(ap, &x);
1357
	bigres(ap, &x);
1290
  return;
1358
	return;
1291
}
1359
}
-
 
1360
 
1292
 
1361
 
1293
/* auxiliary function used for comm_ass by and */
1362
/* auxiliary function used for comm_ass by and */
1294
static void and_fn
-
 
1295
    PROTO_N ( (ap, b, et) )
-
 
1296
    PROTO_T ( exp ap X exp b X int et )
-
 
1297
{
-
 
1298
  flt64 xa, xb;
-
 
1299
  UNUSED (et);
-
 
1300
  xa = exp_to_f64(ap);
-
 
1301
  xb = exp_to_f64(b);
-
 
1302
  xa.small &= xb.small;
-
 
1303
  xa.big &= xb.big;
-
 
1304
  bigres(ap, &xa);
-
 
1305
  return;
-
 
1306
}
-
 
1307
 
1363
 
1308
/* auxiliary function used for comm_ass by or */
-
 
1309
static void or_fn
1364
static void
1310
    PROTO_N ( (ap, b, et) )
-
 
1311
    PROTO_T ( exp ap X exp b X int et )
1365
and_fn(exp ap, exp b, int et)
1312
{
1366
{
1313
  flt64 xa, xb;
1367
	flt64 xa, xb;
1314
  UNUSED (et);
1368
	UNUSED(et);
1315
  xa = exp_to_f64(ap);
1369
	xa = exp_to_f64(ap);
1316
  xb = exp_to_f64(b);
1370
	xb = exp_to_f64(b);
1317
  xa.small |= xb.small;
1371
	xa.small &= xb.small;
1318
  xa.big |= xb.big;
1372
	xa.big &= xb.big;
1319
  bigres(ap, &xa);
1373
	bigres(ap, &xa);
1320
  return;
1374
	return;
1321
}
1375
}
-
 
1376
 
1322
 
1377
 
1323
/* auxiliary function used for comm_ass by xor */
1378
/* auxiliary function used for comm_ass by or */
-
 
1379
 
1324
static void xor_fn
1380
static void
1325
    PROTO_N ( (ap, b, et) )
-
 
1326
    PROTO_T ( exp ap X exp b X int et )
1381
or_fn(exp ap, exp b, int et)
1327
{
1382
{
1328
  flt64 xa, xb;
1383
	flt64 xa, xb;
-
 
1384
	UNUSED(et);
-
 
1385
	xa = exp_to_f64(ap);
-
 
1386
	xb = exp_to_f64(b);
-
 
1387
	xa.small |= xb.small;
-
 
1388
	xa.big |= xb.big;
-
 
1389
	bigres(ap, &xa);
-
 
1390
	return;
-
 
1391
}
-
 
1392
 
-
 
1393
 
-
 
1394
/* auxiliary function used for comm_ass by xor */
-
 
1395
 
-
 
1396
static void
-
 
1397
xor_fn(exp ap, exp b, int et)
-
 
1398
{
-
 
1399
	flt64 xa, xb;
1329
  UNUSED (et);
1400
	UNUSED(et);
1330
  xa = exp_to_f64(ap);
1401
	xa = exp_to_f64(ap);
1331
  xb = exp_to_f64(b);
1402
	xb = exp_to_f64(b);
1332
  xa.small ^= xb.small;
1403
	xa.small ^= xb.small;
1333
  xa.big ^= xb.big;
1404
	xa.big ^= xb.big;
1334
  bigres(ap, &xa);
1405
	bigres(ap, &xa);
1335
  return;
1406
	return;
1336
}
1407
}
-
 
1408
 
1337
 
1409
 
1338
/* not used for comm_ass */
1410
/* not used for comm_ass */
-
 
1411
 
1339
static void domaxmin
1412
static void
1340
    PROTO_N ( (ap, b, mx) )
-
 
1341
    PROTO_T ( exp ap X exp b X int mx )
1413
domaxmin(exp ap, exp b, int mx)
1342
{
1414
{
1343
  flt64 xa, xb;
1415
	flt64 xa, xb;
1344
  int use_a;
1416
	int use_a;
1345
  xa = exp_to_f64(ap);
1417
	xa = exp_to_f64(ap);
1346
  xb = exp_to_f64(b);
1418
	xb = exp_to_f64(b);
1347
  if (is_signed(sh(ap))) {
1419
	if (is_signed(sh(ap))) {
1348
    if (xa.big > xb.big)
1420
		if (xa.big > xb.big) {
1349
      use_a = mx;
1421
			use_a = mx;
-
 
1422
		}
1350
    if (xa.big < xb.big)
1423
		if (xa.big < xb.big) {
1351
      use_a = !mx;
1424
			use_a = !mx;
-
 
1425
		}
1352
    if (xa.big == xb.big) {
1426
		if (xa.big == xb.big) {
1353
      if (xa.small >= xb.small)
1427
			if (xa.small >= xb.small) {
1354
	use_a = mx;
1428
				use_a = mx;
1355
      else
1429
			} else {
1356
	use_a = !mx;
1430
				use_a = !mx;
1357
    };
1431
			}
1358
  }
1432
		}
1359
  else {
1433
	} else {
1360
    if ((unsigned int)xa.big > (unsigned int)xb.big)
1434
		if ((unsigned int)xa.big > (unsigned int)xb.big) {
1361
      use_a = mx;
1435
			use_a = mx;
-
 
1436
		}
1362
    if ((unsigned int)xa.big < (unsigned int)xb.big)
1437
		if ((unsigned int)xa.big < (unsigned int)xb.big) {
1363
      use_a = !mx;
1438
			use_a = !mx;
-
 
1439
		}
1364
    if (xa.big == xb.big) {
1440
		if (xa.big == xb.big) {
1365
      if (xa.small >= xb.small)
1441
			if (xa.small >= xb.small) {
1366
	use_a = mx;
1442
				use_a = mx;
1367
      else
1443
			} else {
1368
	use_a = !mx;
1444
				use_a = !mx;
1369
    };
1445
			}
1370
  };
1446
		}
-
 
1447
	}
1371
  SET(use_a);
1448
	SET(use_a);
1372
  if (use_a)
1449
	if (use_a) {
1373
    bigres(ap, &xa);
1450
		bigres(ap, &xa);
1374
  else
1451
	} else {
1375
    bigres(ap, &xb);
1452
		bigres(ap, &xb);
-
 
1453
	}
1376
  return;
1454
	return;
1377
}
1455
}
-
 
1456
 
1378
 
1457
 
1379
/* produce allones for integer length of shape of e. */
1458
/* produce allones for integer length of shape of e. */
-
 
1459
 
1380
static int  all_ones
1460
static int
1381
    PROTO_N ( (e) )
-
 
1382
    PROTO_T ( exp e )
1461
all_ones(exp e)
1383
{
1462
{
1384
  switch (shape_size(sh(e))) {
1463
	switch (shape_size(sh(e))) {
1385
    case 8:
1464
	case 8:
1386
      return (0xff);
1465
		return(0xff);
1387
    case 16:
1466
	case 16:
1388
      return (0xffff);
1467
		return(0xffff);
1389
    default:
1468
	default:
1390
      return (0xffffffff);
1469
		return(0xffffffff);
1391
  }
1470
	}
1392
}
1471
}
-
 
1472
 
1393
 
1473
 
1394
/* obey div1 on constants */
1474
/* obey div1 on constants */
-
 
1475
 
1395
static void dodiv1
1476
static void
1396
    PROTO_N ( (ap, b) )
-
 
1397
    PROTO_T ( exp ap X exp b )
1477
dodiv1(exp ap, exp b)
1398
{
1478
{
1399
  flt64 x;
1479
	flt64 x;
1400
  flpt fa, fb;
-
 
1401
  int sg = is_signed(sh(ap));
-
 
1402
  flt resval;
-
 
1403
  int ov;
-
 
1404
 
-
 
1405
  fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1406
  fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1407
  IGNORE flt_div (flptnos[fa], flptnos[fb], &resval);
-
 
1408
		/* status cannot be wrong */
-
 
1409
  IGNORE flpt_round_to_integer((int)f_toward_smaller, &resval);
-
 
1410
  flptnos[fa] = resval;
-
 
1411
  x = flt_to_f64(fa, sg, &ov);
-
 
1412
 
-
 
1413
  flpt_ret(fa);
-
 
1414
  flpt_ret(fb);
-
 
1415
 
-
 
1416
  bigres(ap, &x);
-
 
1417
  return;
-
 
1418
}
-
 
1419
 
-
 
1420
/* obey div2 on constants */
-
 
1421
static void dodiv2
-
 
1422
    PROTO_N ( (ap, b) )
-
 
1423
    PROTO_T ( exp ap X exp b )
-
 
1424
{
-
 
1425
  flt64 x;
-
 
1426
  flpt fa, fb;
1480
	flpt fa, fb;
1427
  int sg = is_signed(sh(ap));
1481
	int sg = is_signed(sh(ap));
1428
  flt resval;
1482
	flt resval;
1429
  int ov;
1483
	int ov;
1430
 
-
 
1431
  fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1432
  fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1433
  IGNORE flt_div (flptnos[fa], flptnos[fb], &resval);
-
 
1434
		/* status cannot be wrong */
-
 
1435
 
-
 
1436
  IGNORE flpt_round_to_integer((int)f_toward_zero, &resval);
-
 
1437
 
-
 
1438
  flptnos[fa] = resval;
-
 
1439
  x = flt_to_f64(fa, sg, &ov);
-
 
1440
 
1484
 
-
 
1485
	fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1486
	fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1487
	IGNORE flt_div(flptnos[fa], flptnos[fb], &resval);
-
 
1488
	/* status cannot be wrong */
-
 
1489
	IGNORE flpt_round_to_integer((int)f_toward_smaller, &resval);
1441
  flpt_ret(fa);
1490
	flptnos[fa] = resval;
1442
  flpt_ret(fb);
1491
	x = flt_to_f64(fa, sg, &ov);
1443
 
1492
 
-
 
1493
	flpt_ret(fa);
-
 
1494
	flpt_ret(fb);
-
 
1495
 
1444
  bigres(ap, &x);
1496
	bigres(ap, &x);
1445
  return;
1497
	return;
1446
}
1498
}
1447
 
1499
 
-
 
1500
 
1448
/* obey mod on constants */
1501
/* obey div2 on constants */
-
 
1502
 
1449
static void domod
1503
static void
1450
    PROTO_N ( (ap, b) )
-
 
1451
    PROTO_T ( exp ap X exp b )
1504
dodiv2(exp ap, exp b)
1452
{
1505
{
-
 
1506
	flt64 x;
-
 
1507
	flpt fa, fb;
-
 
1508
	int sg = is_signed(sh(ap));
-
 
1509
	flt resval;
-
 
1510
	int ov;
-
 
1511
 
-
 
1512
	fa = f64_to_flt(exp_to_f64(ap), sg);
-
 
1513
	fb = f64_to_flt(exp_to_f64(b), sg);
-
 
1514
	IGNORE flt_div(flptnos[fa], flptnos[fb], &resval);
-
 
1515
	/* status cannot be wrong */
-
 
1516
 
-
 
1517
	IGNORE flpt_round_to_integer((int)f_toward_zero, &resval);
-
 
1518
 
-
 
1519
	flptnos[fa] = resval;
-
 
1520
	x = flt_to_f64(fa, sg, &ov);
-
 
1521
 
-
 
1522
	flpt_ret(fa);
-
 
1523
	flpt_ret(fb);
-
 
1524
 
-
 
1525
	bigres(ap, &x);
-
 
1526
	return;
-
 
1527
}
-
 
1528
 
-
 
1529
 
-
 
1530
/* obey mod on constants */
-
 
1531
 
-
 
1532
static void
-
 
1533
domod(exp ap, exp b)
-
 
1534
{
1453
  exp top = copy(ap);
1535
	exp top = copy(ap);
1454
 
1536
 
1455
  dodiv1(top, b);
1537
	dodiv1(top, b);
1456
  mult_fn(b, top, f_wrap.err_code);
1538
	mult_fn(b, top, f_wrap.err_code);
1457
  neg_fn(b);
1539
	neg_fn(b);
1458
  plus_fn(ap, b, f_wrap.err_code);
1540
	plus_fn(ap, b, f_wrap.err_code);
1459
  return;
1541
	return;
1460
}
1542
}
-
 
1543
 
1461
 
1544
 
1462
/* obey rem2 on constants */
1545
/* obey rem2 on constants */
-
 
1546
 
1463
static void dorem2
1547
static void
1464
    PROTO_N ( (ap, b) )
-
 
1465
    PROTO_T ( exp ap X exp b )
1548
dorem2(exp ap, exp b)
1466
{
1549
{
1467
  exp top = copy(ap);
1550
	exp top = copy(ap);
1468
 
1551
 
1469
  dodiv2(top, b);
1552
	dodiv2(top, b);
1470
  mult_fn(b, top, f_wrap.err_code);
1553
	mult_fn(b, top, f_wrap.err_code);
1471
  neg_fn(b);
1554
	neg_fn(b);
1472
  plus_fn(ap, b, f_wrap.err_code);
1555
	plus_fn(ap, b, f_wrap.err_code);
1473
  return;
1556
	return;
1474
}
1557
}
-
 
1558
 
1475
 
1559
 
1476
/* obey shift (places signed) on constants */
1560
/* obey shift (places signed) on constants */
-
 
1561
 
1477
static void  doshl
1562
static void
1478
    PROTO_N ( (e) )
-
 
1479
    PROTO_T ( exp e )
1563
doshl(exp e)
1480
{
1564
{
1481
  flt64 x;
1565
	flt64 x;
1482
  exp arg1 = son(e);
1566
	exp arg1 = son(e);
1483
  exp arg2 = bro(arg1);
1567
	exp arg2 = bro(arg1);
1484
  int pl = no(arg2);
1568
	int pl = no(arg2);
1485
  shape sha = sh(e);
1569
	shape sha = sh(e);
1486
  int sg = is_signed(sha);
1570
	int sg = is_signed(sha);
1487
 
1571
 
1488
  sh(arg1) = sh(e);
1572
	sh(arg1) = sh(e);
1489
 
1573
 
1490
  x = exp_to_f64(arg1);
1574
	x = exp_to_f64(arg1);
1491
 
1575
 
1492
  if (name(e) == shl_tag)  { /* shift left */
1576
	if (name(e) == shl_tag) {
-
 
1577
		/* shift left */
1493
    if (isbigval(arg2) || pl >= shape_size(sha)) {
1578
		if (isbigval(arg2) || pl >= shape_size(sha)) {
1494
      no(arg1) = 0;
1579
			no(arg1) = 0;
1495
      clearbigval(arg1);
1580
			clearbigval(arg1);
1496
      return;
1581
			return;
1497
    };
1582
		}
1498
    if (pl >= 32)  {
1583
		if (pl >= 32) {
1499
      x.big = (int)(x.small << (pl-32));
1584
			x.big = (int)(x.small << (pl - 32));
1500
      x.small = 0;
1585
			x.small = 0;
1501
    }
-
 
1502
    else  {
1586
		} else {
1503
      x.big <<= pl;
1587
			x.big <<= pl;
1504
      x.big |= (int)(x.small >> (32-pl));
1588
			x.big |= (int)(x.small >> (32 - pl));
1505
      x.small <<= pl;
1589
			x.small <<= pl;
1506
    };
1590
		}
1507
  }
1591
	} else {
1508
  else  {  /* shift right */
1592
		/* shift right */
1509
    if (isbigval(arg2) || pl >= shape_size(sha)) {
1593
		if (isbigval(arg2) || pl >= shape_size(sha)) {
1510
      no(arg1) = 0;
1594
			no(arg1) = 0;
1511
      if (sg) {
1595
			if (sg) {
1512
	if (isbigval(arg1)) {
1596
				if (isbigval(arg1)) {
1513
	  if (flptnos[no(arg1)].sign == -1)
1597
					if (flptnos[no(arg1)].sign == -1) {
1514
	    no(arg1) = -1;
1598
						no(arg1) = -1;
1515
	}
-
 
1516
	else
1599
					}
1517
	if (no(arg1) < 0)
1600
				} else if (no(arg1) < 0) {
1518
	  no(arg1) = -1;
1601
						no(arg1) = -1;
1519
      };
1602
				}
-
 
1603
			}
1520
      clearbigval(arg1);
1604
			clearbigval(arg1);
1521
      return;
1605
			return;
1522
    };
1606
		}
1523
    if (pl >= 32) {
1607
		if (pl >= 32) {
1524
      if (sg)  {
1608
			if (sg) {
1525
	x.small = (unsigned int)(x.big >> (pl-32));
1609
				x.small = (unsigned int)(x.big >> (pl - 32));
1526
	x.big = x.big >> 31;
1610
				x.big = x.big >> 31;
1527
      }
-
 
1528
      else {
1611
			} else {
1529
	x.small = ((unsigned int)x.big) >> (pl-32);
1612
				x.small = ((unsigned int)x.big) >> (pl - 32);
1530
	x.big = 0;
1613
				x.big = 0;
1531
      };
-
 
1532
    }
1614
			}
1533
    else  {
1615
		} else {
1534
      if (sg)  {
1616
			if (sg) {
1535
	x.small >>= pl;
1617
				x.small >>= pl;
1536
	x.small |= (unsigned int)(x.big << (32-pl));
1618
				x.small |= (unsigned int)(x.big << (32 - pl));
1537
	x.big >>= pl;
1619
				x.big >>= pl;
1538
      }
-
 
1539
      else {
1620
			} else {
1540
	x.small >>= pl;
1621
				x.small >>= pl;
1541
	x.small |= (unsigned int)(x.big << (32-pl));
1622
				x.small |= (unsigned int)(x.big << (32 - pl));
1542
	x.big = (int)(((unsigned int)x.big) >> pl);
1623
				x.big = (int)(((unsigned int)x.big) >> pl);
1543
      };
1624
			}
1544
    };
1625
		}
1545
  };
1626
	}
1546
  bigres(arg1, &x);
1627
	bigres(arg1, &x);
1547
  return;
1628
	return;
1548
}
1629
}
1549
 
-
 
1550
 
-
 
1551
 
1630
 
1552
 
1631
 
1553
#if has_setcc
1632
#if has_setcc
1554
 
1633
 
1555
 /* included if target has a setcc operation, to set a bit from the
1634
 /* included if target has a setcc operation, to set a bit from the
1556
    condition flags */
1635
    condition flags */
1557
 
1636
 
1558
static exp absbool
1637
static exp
1559
    PROTO_N ( (id) )
-
 
1560
    PROTO_T ( exp id )
1638
absbool(exp id)
1561
{
1639
{
1562
				/* check if e  is (let a = 0 in
-
 
1563
				   cond(test(L)=result; a=1 | L:top); a )
1640
	/* check if e is (let a = 0 in cond(test(L) = result; a = 1 | L:top); a)
1564
				   If so, return the test, otherwise
1641
	   If so, return the test, otherwise nilexp. */
1565
				   nilexp. */
-
 
1566
  if (isvar (id) && name (son (id)) == val_tag && no (son (id)) == 0 &&
1642
	if (isvar(id) && name(son(id)) == val_tag && no(son(id)) == 0 &&
1567
	!isbigval(son(id))
-
 
1568
      && no (id) == 2) {
1643
	    !isbigval(son(id)) && no(id) == 2) {
1569
	/* name initially 0 only used twice */
1644
		/* name initially 0 only used twice */
1570
    exp bdy = bro (son (id));
1645
		exp bdy = bro(son(id));
1571
    if (name (bdy) == seq_tag && name (bro (son (bdy))) == cont_tag &&
1646
		if (name(bdy) == seq_tag && name(bro(son(bdy))) == cont_tag &&
1572
	name (son (bro (son (bdy)))) == name_tag &&
1647
		    name(son(bro(son(bdy)))) == name_tag &&
1573
	son (son (bro (son (bdy)))) == id) {
1648
		    son(son(bro(son(bdy)))) == id) {
1574
	/* one use is result  of sequence body */
1649
			/* one use is result of sequence body */
1575
      exp c = son (son (bdy));
1650
			exp c = son(son(bdy));
1576
#ifndef NEWDIAGS
1651
#ifndef NEWDIAGS
1577
      if (name(c) == diagnose_tag)
1652
			if (name(c) == diagnose_tag) {
1578
        c = son(c);
1653
				c = son(c);
-
 
1654
			}
1579
#endif
1655
#endif
1580
      if (last (c) && name (c) == cond_tag) {
1656
			if (last(c) && name(c) == cond_tag) {
1581
	/* seq is cond=c; id */
1657
				/* seq is cond=c; id */
1582
	exp first = son (c);
1658
				exp first = son(c);
1583
	exp second = bro (son (c));
1659
				exp second = bro(son(c));
1584
	if (no (son (second)) == 1 /* only one jump to else */ &&
1660
				/* only one jump to else */
-
 
1661
				if (no(son(second)) == 1 &&
1585
	    name (bro (son (second))) == top_tag
1662
				    name(bro(son(second))) == top_tag &&
1586
	    && name (first) == seq_tag) {
1663
				    name(first) == seq_tag) {
1587
	  /* cond is (seq= first | L: top) */
1664
					/* cond is (seq = first | L: top) */
1588
	  exp s = son (son (first));
1665
					exp s = son(son(first));
1589
	  exp r = bro (son (first));
1666
					exp r = bro(son(first));
-
 
1667
					/* last of seq is id = 1 */
-
 
1668
					/* start of seq is int test jumping to
-
 
1669
					 * second */
-
 
1670
					if (name(r) == ass_tag &&
1590
	  if (name (r) == ass_tag && name (son (r)) == name_tag &&
1671
					    name(son(r)) == name_tag &&
-
 
1672
					    son(son(r)) == id &&
1591
	      son (son (r)) == id && name (bro (son (r))) == val_tag &&
1673
					    name(bro(son(r))) == val_tag &&
1592
		!isbigval(bro(son(r))) &&
1674
					    !isbigval(bro(son(r))) &&
1593
	      no (bro (son (r))) == 1 /* last of seq is id = 1 */ &&
1675
					    no(bro(son(r))) == 1 &&
1594
	      last (s) && name (s) == test_tag && pt (s) == second
1676
					    last(s) && name(s) == test_tag &&
1595
	  /* start of seq is int test jumping to second */
1677
					    pt(s) == second) {
1596
	    )
-
 
1597
	    return s;
1678
						return s;
-
 
1679
					}
1598
	} /* cond is (seq= first | L: top) */
1680
				} /* cond is (seq= first | L: top) */
1599
      }; /* seq is cond=c; id */
1681
			} /* seq is cond=c; id */
1600
      if (last(c) && name(c) == condassign_tag) {
1682
			if (last(c) && name(c) == condassign_tag) {
1601
	/* seq is condassign = c; id */
1683
				/* seq is condassign = c; id */
1602
	exp s = son (c);
1684
				exp s = son(c);
1603
	exp r = bro (s);
1685
				exp r = bro(s);
-
 
1686
				/* last of seq is id = 1 */
1604
	if (name (son (r)) == name_tag &&
1687
				if (name(son(r)) == name_tag &&
-
 
1688
				    son(son(r)) == id &&
1605
		son (son (r)) == id && name (bro (son (r))) == val_tag &&
1689
				    name(bro(son(r))) == val_tag &&
1606
		!isbigval(bro(son(r))) &&
1690
				    !isbigval(bro(son(r))) &&
1607
	      no (bro (son (r))) == 1 /* last of seq is id = 1 */)
1691
				    no(bro(son(r))) == 1) {
1608
	  return s;
1692
					return s;
-
 
1693
				}
1609
      }; /* seq is condassign = c; id */
1694
			} /* seq is condassign = c; id */
1610
    } /* one use is result  of sequence body */
1695
		} /* one use is result of sequence body */
1611
  } /* name initially 0 only used twice */
1696
	} /* name initially 0 only used twice */
1612
  return nilexp;
1697
	return nilexp;
1613
}
1698
}
1614
#endif
1699
#endif
1615
 
1700
 
1616
 
1701
 
1617
 /* distributes the operation e into a sequence, ie if e = op(seq(d ...;
1702
 /* distributes the operation e into a sequence, ie if e = op(seq(d ...;
1618
    c), a) produces seq(d...; op(c,a))  */
1703
    c), a) produces seq(d...; op(c, a)) */
1619
static int seq_distr
1704
static int
1620
    PROTO_N ( (e, scope) )
-
 
1621
    PROTO_T ( exp e X exp scope )
1705
seq_distr(exp e, exp scope)
1622
{
1706
{
1623
  exp x = son(e);
1707
	exp x = son(e);
1624
  exp y;
1708
	exp y;
1625
  if (last(x) || (!last(x) && last(bro(x)))) {
1709
	if (last(x) || (!last(x) && last(bro(x)))) {
1626
    if (name(x) == seq_tag || name(x) == ident_tag) {
1710
		if (name(x) == seq_tag || name(x) == ident_tag) {
1627
      exp b = bro(son(x));
1711
			exp b = bro(son(x));
1628
      exp r;
1712
			exp r;
1629
      if (name(x) == ident_tag) { clearinlined(x); }
1713
			if (name(x) == ident_tag) {
1630
      if (last(x))
1714
				clearinlined(x);
1631
	r = me_u3(sh(e), copy(b), name(e));
-
 
1632
      else {
1715
			}
1633
#ifdef NEWDIAGS
-
 
1634
	if (diagnose)
1716
			if (last(x)) {
1635
	  dg_restruct_code (x, bro(x), +1);
-
 
1636
#endif
-
 
1637
	r = me_b3(sh(e), copy(b), bro(x), name(e));
1717
				r = me_u3(sh(e), copy(b), name(e));
1638
      }
1718
			} else {
1639
      pt(r) = pt(e);
-
 
1640
      no(r) = no(e);
-
 
1641
      props(r) = props(e);
-
 
1642
      r = hold_check(r);
-
 
1643
      sh(x) = sh(e);
-
 
1644
      replace(b, r, r);		/* dgf preserved in copy */
-
 
1645
      kill_exp(b, b);
-
 
1646
#ifdef NEWDIAGS
1719
#ifdef NEWDIAGS
1647
      if (diagnose)
1720
				if (diagnose) {
1648
	dg_whole_comp (e, x);
1721
					dg_restruct_code(x, bro(x), +1);
-
 
1722
				}
1649
#endif
1723
#endif
-
 
1724
				r = me_b3(sh(e), copy(b), bro(x), name(e));
-
 
1725
			}
-
 
1726
			pt(r) = pt(e);
-
 
1727
			no(r) = no(e);
-
 
1728
			props(r) = props(e);
-
 
1729
			r = hold_check(r);
-
 
1730
			sh(x) = sh(e);
-
 
1731
			replace(b, r, r);	/* dgf preserved in copy */
-
 
1732
			kill_exp(b, b);
-
 
1733
#ifdef NEWDIAGS
-
 
1734
			if (diagnose) {
-
 
1735
				dg_whole_comp(e, x);
-
 
1736
			}
-
 
1737
#endif
1650
      replace(e, x, scope);
1738
			replace(e, x, scope);
1651
      return 1;
1739
			return 1;
1652
    };
1740
		}
1653
  };
1741
	}
1654
  if (!last(x) && last(bro(x))) {
1742
	if (!last(x) && last(bro(x))) {
1655
    y = bro(x);
1743
		y = bro(x);
1656
    if (name(y) == seq_tag || name(y) == ident_tag) {
1744
		if (name(y) == seq_tag || name(y) == ident_tag) {
1657
      exp b = bro(son(y));
1745
			exp b = bro(son(y));
1658
      exp r;
1746
			exp r;
1659
      if (name(y) == ident_tag) { clearinlined(y); }
1747
			if (name(y) == ident_tag) {
-
 
1748
				clearinlined(y);
-
 
1749
			}
-
 
1750
#ifdef NEWDIAGS
-
 
1751
			if (diagnose) {
-
 
1752
				dg_restruct_code(y, x, -1);
-
 
1753
			}
-
 
1754
#endif
-
 
1755
			r = me_b3(sh(e), x, copy(b), name(e));
-
 
1756
			pt(r) = pt(e);
-
 
1757
			no(r) = no(e);
-
 
1758
			props(r) = props(e);
-
 
1759
			r = hold_check(r);
-
 
1760
			sh(y) = sh(e);
-
 
1761
			replace(b, r, r);		/* dgf preserved in copy */
-
 
1762
			kill_exp(b, b);
1660
#ifdef NEWDIAGS
1763
#ifdef NEWDIAGS
1661
      if (diagnose)
1764
			if (diagnose) {
1662
	dg_restruct_code (y, x, -1);
1765
				dg_whole_comp(e, y);
-
 
1766
			}
1663
#endif
1767
#endif
1664
      r = me_b3(sh(e), x, copy(b), name(e));
-
 
1665
      pt(r) = pt(e);
-
 
1666
      no(r) = no(e);
-
 
1667
      props(r) = props(e);
-
 
1668
      r = hold_check(r);
-
 
1669
      sh(y) = sh(e);
-
 
1670
      replace(b, r, r);		/* dgf preserved in copy */
-
 
1671
      kill_exp(b, b);
-
 
1672
#ifdef NEWDIAGS
-
 
1673
      if (diagnose)
-
 
1674
	dg_whole_comp (e, y);
-
 
1675
#endif
-
 
1676
      replace(e, y, scope);
1768
			replace(e, y, scope);
1677
      return 1;
1769
			return 1;
1678
    };
1770
		}
1679
  };
1771
	}
1680
  return 0;
1772
	return 0;
1681
}
1773
}
1682
 
1774
 
1683
 /* reverses (ie. nots) test numbers */
1775
 /* reverses (ie. nots) test numbers */
1684
unsigned char  revtest[6] = {
1776
unsigned char revtest[6] = {
1685
  4, 3, 2, 1, 6, 5
1777
	4, 3, 2, 1, 6, 5
1686
};
1778
};
1687
 
1779
 
1688
 
1780
 
1689
/* returns sign if |f|=1, otherwise 0 */
1781
/* returns sign if |f|=1, otherwise 0 */
1690
static int  f_one
-
 
1691
    PROTO_N ( (f) )
-
 
1692
    PROTO_T ( flpt f )
-
 
1693
{
-
 
1694
  flt fconst;
-
 
1695
  fconst = flptnos[f];
-
 
1696
 
1782
 
1697
  if (fconst.mant[0] == 1 && fconst.exp == 0) {
-
 
1698
    int   i = 1;
-
 
1699
    while (i < MANT_SIZE && fconst.mant[i] == 0)
-
 
1700
      ++i;
-
 
1701
    if (i == MANT_SIZE)
-
 
1702
      return (fconst.sign);
-
 
1703
    else
-
 
1704
      return (0);
-
 
1705
  }
-
 
1706
  else
-
 
1707
    return (0);
-
 
1708
}
-
 
1709
 
-
 
1710
 
-
 
1711
/* applies fneg */
-
 
1712
static  exp fneg
1783
static int
1713
    PROTO_N ( (e) )
1784
f_one(flpt f)
1714
    PROTO_T ( exp e )
-
 
1715
{
1785
{
-
 
1786
	flt fconst;
-
 
1787
	fconst = flptnos[f];
-
 
1788
 
-
 
1789
	if (fconst.mant[0] == 1 && fconst.exp == 0) {
-
 
1790
		int i = 1;
-
 
1791
		while (i < MANT_SIZE && fconst.mant[i] == 0) {
-
 
1792
			++i;
-
 
1793
		}
-
 
1794
		if (i == MANT_SIZE) {
-
 
1795
			return(fconst.sign);
-
 
1796
		} else {
-
 
1797
			return(0);
-
 
1798
		}
-
 
1799
	} else {
-
 
1800
		return(0);
-
 
1801
	}
-
 
1802
}
-
 
1803
 
-
 
1804
 
-
 
1805
/* applies fneg */
-
 
1806
 
-
 
1807
static exp
-
 
1808
fneg(exp e)
-
 
1809
{
1716
  exp n = getexp (sh (e), nilexp, 0, e, nilexp, 0, 0, fneg_tag);
1810
	exp n = getexp(sh(e), nilexp, 0, e, nilexp, 0, 0, fneg_tag);
1717
  setlast (e);
1811
	setlast(e);
1718
  bro (e) = n;
1812
	bro(e) = n;
1719
  return (n);
1813
	return(n);
1720
}
1814
}
1721
 
1815
 
1722
 
1816
 
1723
/* applies binary floating point operations */
1817
/* applies binary floating point operations */
1724
static  int check_fp2
-
 
1725
    PROTO_N ( (e, scope) )
-
 
1726
    PROTO_T ( exp e X exp scope )
-
 
1727
{
-
 
1728
  exp a1 = son (e);
-
 
1729
  exp a2 = bro (a1);
-
 
1730
  flpt f1, f2;
-
 
1731
  flt resval;
-
 
1732
  int   status;
-
 
1733
 
1818
 
1861
	}
1956
	}
1862
    }
-
 
1863
  };
-
 
1864
  return (0);
1957
	return(0);
1865
}
-
 
1866
 
-
 
1867
/* compares integer constants using the test given by test_no */
-
 
1868
static int docmp
-
 
1869
    PROTO_N ( (sha, test_no, c1, c2) )
-
 
1870
    PROTO_T ( shape sha X unsigned char test_no X int c1 X int c2 )
-
 
1871
{
-
 
1872
  int c;
-
 
1873
  switch (shape_size(sha)) EXHAUSTIVE {
-
 
1874
    case 8:
-
 
1875
     if (is_signed(sha))
-
 
1876
      {
-
 
1877
	int   d1 = (c1 & 0x80) ? (c1 | ~0x7f) : (c1 & 0xff);
-
 
1878
	int   d2 = (c2 & 0x80) ? (c2 | ~0x7f) : (c2 & 0xff);
-
 
1879
	switch (test_no) EXHAUSTIVE {
-
 
1880
	  case 1:
-
 
1881
	    c = (d1 > d2);
-
 
1882
	    break;
-
 
1883
	  case 2:
-
 
1884
	    c = (d1 >= d2);
-
 
1885
	    break;
-
 
1886
	  case 3:
-
 
1887
	    c = (d1 < d2);
-
 
1888
	    break;
-
 
1889
	  case 4:
-
 
1890
	    c = (d1 <= d2);
-
 
1891
	    break;
-
 
1892
	  case 5:
-
 
1893
	    c = (d1 == d2);
-
 
1894
	    break;
-
 
1895
	  case 6:
-
 
1896
	    c = (d1 != d2);
-
 
1897
	    break;
-
 
1898
	};
-
 
1899
	break;
-
 
1900
      }
-
 
1901
      else
-
 
1902
      {
-
 
1903
	unsigned char d1 = (unsigned char)(c1 & 0xff);
-
 
1904
	unsigned char d2 = (unsigned char)(c2 & 0xff);
-
 
1905
	switch (test_no) EXHAUSTIVE {
-
 
1906
	  case 1:
-
 
1907
	    c = (d1 > d2);
-
 
1908
	    break;
-
 
1909
	  case 2:
-
 
1910
	    c = (d1 >= d2);
-
 
1911
	    break;
-
 
1912
	  case 3:
-
 
1913
	    c = (d1 < d2);
-
 
1914
	    break;
-
 
1915
	  case 4:
-
 
1916
	    c = (d1 <= d2);
-
 
1917
	    break;
-
 
1918
	  case 5:
-
 
1919
	    c = (d1 == d2);
-
 
1920
	    break;
-
 
1921
	  case 6:
-
 
1922
	    c = (d1 != d2);
-
 
1923
	    break;
-
 
1924
	};
-
 
1925
	break;
-
 
1926
      };
-
 
1927
    case 16:
-
 
1928
     if (is_signed(sha))
-
 
1929
      {
-
 
1930
	int   d1 = (c1 & 0x8000) ? (c1 | ~0x7fff) : (c1 & 0xffff);
-
 
1931
	int   d2 = (c2 & 0x8000) ? (c2 | ~0x7fff) : (c2 & 0xffff);
-
 
1932
	switch (test_no) EXHAUSTIVE {
-
 
1933
	  case 1:
-
 
1934
	    c = (d1 > d2);
-
 
1935
	    break;
-
 
1936
	  case 2:
-
 
1937
	    c = (d1 >= d2);
-
 
1938
	    break;
-
 
1939
	  case 3:
-
 
1940
	    c = (d1 < d2);
-
 
1941
	    break;
-
 
1942
	  case 4:
-
 
1943
	    c = (d1 <= d2);
-
 
1944
	    break;
-
 
1945
	  case 5:
-
 
1946
	    c = (d1 == d2);
-
 
1947
	    break;
-
 
1948
	  case 6:
-
 
1949
	    c = (d1 != d2);
-
 
1950
	    break;
-
 
1951
	};
-
 
1952
	break;
-
 
1953
      }
-
 
1954
     else
-
 
1955
      {
-
 
1956
	unsigned short  d1 = (unsigned short)(c1 & 0xffff);
-
 
1957
	unsigned short  d2 = (unsigned short)(c2 & 0xffff);
-
 
1958
	switch (test_no) EXHAUSTIVE {
-
 
1959
	  case 1:
-
 
1960
	    c = (d1 > d2);
-
 
1961
	    break;
-
 
1962
	  case 2:
-
 
1963
	    c = (d1 >= d2);
-
 
1964
	    break;
-
 
1965
	  case 3:
-
 
1966
	    c = (d1 < d2);
-
 
1967
	    break;
-
 
1968
	  case 4:
-
 
1969
	    c = (d1 <= d2);
-
 
1970
	    break;
-
 
1971
	  case 5:
-
 
1972
	    c = (d1 == d2);
-
 
1973
	    break;
-
 
1974
	  case 6:
-
 
1975
	    c = (d1 != d2);
-
 
1976
	    break;
-
 
1977
	};
-
 
1978
	break;
-
 
1979
      };
-
 
1980
    case 32:
-
 
1981
     if (is_signed(sha))
-
 
1982
      {
-
 
1983
	int  d1 = c1;
-
 
1984
	int  d2 = c2;
-
 
1985
	switch (test_no) EXHAUSTIVE {
-
 
1986
	  case 1:
-
 
1987
	    c = (d1 > d2);
-
 
1988
	    break;
-
 
1989
	  case 2:
-
 
1990
	    c = (d1 >= d2);
-
 
1991
	    break;
-
 
1992
	  case 3:
-
 
1993
	    c = (d1 < d2);
-
 
1994
	    break;
-
 
1995
	  case 4:
-
 
1996
	    c = (d1 <= d2);
-
 
1997
	    break;
-
 
1998
	  case 5:
-
 
1999
	    c = (d1 == d2);
-
 
2000
	    break;
-
 
2001
	  case 6:
-
 
2002
	    c = (d1 != d2);
-
 
2003
	    break;
-
 
2004
	};
-
 
2005
	break;
-
 
2006
      }
-
 
2007
     else
-
 
2008
      {
-
 
2009
	unsigned int d1 = (unsigned int)c1;
-
 
2010
	unsigned int d2 = (unsigned int)c2;
-
 
2011
	switch (test_no) EXHAUSTIVE {
-
 
2012
	  case 1:
-
 
2013
	    c = (d1 > d2);
-
 
2014
	    break;
-
 
2015
	  case 2:
-
 
2016
	    c = (d1 >= d2);
-
 
2017
	    break;
-
 
2018
	  case 3:
-
 
2019
	    c = (d1 < d2);
-
 
2020
	    break;
-
 
2021
	  case 4:
-
 
2022
	    c = (d1 <= d2);
-
 
2023
	    break;
-
 
2024
	  case 5:
-
 
2025
	    c = (d1 == d2);
-
 
2026
	    break;
-
 
2027
	  case 6:
-
 
2028
	    c = (d1 != d2);
-
 
2029
	    break;
-
 
2030
	};
-
 
2031
	break;
-
 
2032
      };
-
 
2033
  };
-
 
2034
  return (c);
-
 
2035
}
1958
}
2036
 
1959
 
2037
 
1960
 
2038
int docmp_f
-
 
2039
    PROTO_N ( (test_no, a, b) )
-
 
2040
    PROTO_T ( int test_no X exp a X exp b )
-
 
2041
{
-
 
2042
  shape sha = sh(a);
-
 
2043
  flt64 xa, xb;
-
 
2044
  int sg = is_signed(sha);
-
 
2045
  int eq = 0;
-
 
2046
  int less = 0;
-
 
2047
  int gr = 0;
-
 
2048
  int c;
-
 
2049
 
-
 
2050
  if (shape_size(sh(a)) <= 32)
-
 
2051
    return docmp(sha, (unsigned char)test_no, no(a), no(b));
1961
/* compares integer constants using the test given by test_no */
2052
 
-
 
2053
  xa = exp_to_f64(a);
-
 
2054
  xb = exp_to_f64(b);
-
 
2055
 
-
 
2056
  if (xa.big == xb.big && xa.small == xb.small)
-
 
2057
    eq = 1;
-
 
2058
 
-
 
2059
  if (sg && !eq) {
-
 
2060
    if (xa.big < xb.big)
-
 
2061
      less = 1;
-
 
2062
    else
-
 
2063
    if (xa.big > xb.big)
-
 
2064
      gr = 1;
-
 
2065
    else {
-
 
2066
      if (xa.small < xb.small)
-
 
2067
	less = 1;
-
 
2068
      else
-
 
2069
	gr = 1;
-
 
2070
    };
-
 
2071
  }
-
 
2072
  else
-
 
2073
  if (!eq) {
-
 
2074
    if ((unsigned int)xa.big < (unsigned int)xb.big)
-
 
2075
      less = 1;
-
 
2076
    else
-
 
2077
    if ((unsigned int)xa.big > (unsigned int)xb.big)
-
 
2078
      gr = 1;
-
 
2079
    else {
-
 
2080
      if (xa.small < xb.small)
-
 
2081
	less = 1;
-
 
2082
      else
-
 
2083
	gr = 1;
-
 
2084
    };
-
 
2085
  };
-
 
2086
 
-
 
2087
  switch (test_no) EXHAUSTIVE {
-
 
2088
	  case 1:
-
 
2089
	    c = gr;
-
 
2090
	    break;
-
 
2091
	  case 2:
-
 
2092
	    c = gr | eq;
-
 
2093
	    break;
-
 
2094
	  case 3:
-
 
2095
	    c = less;
-
 
2096
	    break;
-
 
2097
	  case 4:
-
 
2098
	    c = less | eq;
-
 
2099
	    break;
-
 
2100
	  case 5:
-
 
2101
	    c = eq;
-
 
2102
	    break;
-
 
2103
	  case 6:
-
 
2104
	    c = !eq;
-
 
2105
	    break;
-
 
2106
  };
-
 
2107
  return c;
-
 
2108
}
-
 
2109
 
1962
 
-
 
1963
static int
-
 
1964
docmp(shape sha, unsigned char test_no, int c1, int c2)
-
 
1965
{
-
 
1966
	int c;
-
 
1967
	switch (shape_size(sha))EXHAUSTIVE {
-
 
1968
	case 8:
-
 
1969
		if (is_signed(sha)) {
-
 
1970
			int d1 = (c1 & 0x80) ? (c1 | ~0x7f) : (c1 & 0xff);
-
 
1971
			int d2 = (c2 & 0x80) ? (c2 | ~0x7f) : (c2 & 0xff);
-
 
1972
			switch (test_no)EXHAUSTIVE {
-
 
1973
			case 1:
-
 
1974
				c = (d1 > d2);
-
 
1975
				break;
-
 
1976
			case 2:
-
 
1977
				c = (d1 >= d2);
-
 
1978
				break;
-
 
1979
			case 3:
-
 
1980
				c = (d1 < d2);
-
 
1981
				break;
-
 
1982
			case 4:
-
 
1983
				c = (d1 <= d2);
-
 
1984
				break;
-
 
1985
			case 5:
-
 
1986
				c = (d1 == d2);
-
 
1987
				break;
-
 
1988
			case 6:
-
 
1989
				c = (d1 != d2);
-
 
1990
				break;
-
 
1991
			}
-
 
1992
			break;
-
 
1993
		} else {
-
 
1994
			unsigned char d1 = (unsigned char)(c1 & 0xff);
-
 
1995
			unsigned char d2 = (unsigned char)(c2 & 0xff);
-
 
1996
			switch (test_no)EXHAUSTIVE {
-
 
1997
			case 1:
-
 
1998
				c = (d1 > d2);
-
 
1999
				break;
-
 
2000
			case 2:
-
 
2001
				c = (d1 >= d2);
-
 
2002
				break;
-
 
2003
			case 3:
-
 
2004
				c = (d1 < d2);
-
 
2005
				break;
-
 
2006
			case 4:
-
 
2007
				c = (d1 <= d2);
-
 
2008
				break;
-
 
2009
			case 5:
-
 
2010
				c = (d1 == d2);
-
 
2011
				break;
-
 
2012
			case 6:
-
 
2013
				c = (d1 != d2);
-
 
2014
				break;
-
 
2015
			}
-
 
2016
			break;
-
 
2017
		}
-
 
2018
	case 16:
-
 
2019
		if (is_signed(sha)) {
-
 
2020
			int d1 = (c1 & 0x8000) ? (c1 | ~0x7fff) : (c1 & 0xffff);
-
 
2021
			int d2 = (c2 & 0x8000) ? (c2 | ~0x7fff) : (c2 & 0xffff);
-
 
2022
			switch (test_no)EXHAUSTIVE {
-
 
2023
			case 1:
-
 
2024
				c = (d1 > d2);
-
 
2025
				break;
-
 
2026
			case 2:
-
 
2027
				c = (d1 >= d2);
-
 
2028
				break;
-
 
2029
			case 3:
-
 
2030
				c = (d1 < d2);
-
 
2031
				break;
-
 
2032
			case 4:
-
 
2033
				c = (d1 <= d2);
-
 
2034
				break;
-
 
2035
			case 5:
-
 
2036
				c = (d1 == d2);
-
 
2037
				break;
-
 
2038
			case 6:
-
 
2039
				c = (d1 != d2);
-
 
2040
				break;
-
 
2041
			}
-
 
2042
			break;
-
 
2043
		} else {
-
 
2044
			unsigned short d1 = (unsigned short)(c1 & 0xffff);
-
 
2045
			unsigned short d2 = (unsigned short)(c2 & 0xffff);
-
 
2046
			switch (test_no)EXHAUSTIVE {
-
 
2047
			case 1:
-
 
2048
				c = (d1 > d2);
-
 
2049
				break;
-
 
2050
			case 2:
-
 
2051
				c = (d1 >= d2);
-
 
2052
				break;
-
 
2053
			case 3:
-
 
2054
				c = (d1 < d2);
-
 
2055
				break;
-
 
2056
			case 4:
-
 
2057
				c = (d1 <= d2);
-
 
2058
				break;
-
 
2059
			case 5:
-
 
2060
				c = (d1 == d2);
-
 
2061
				break;
-
 
2062
			case 6:
-
 
2063
				c = (d1 != d2);
-
 
2064
				break;
-
 
2065
			}
-
 
2066
			break;
-
 
2067
		}
-
 
2068
	case 32:
-
 
2069
		if (is_signed(sha)) {
-
 
2070
			int d1 = c1;
-
 
2071
			int d2 = c2;
-
 
2072
			switch (test_no)EXHAUSTIVE {
-
 
2073
			case 1:
-
 
2074
				c = (d1 > d2);
-
 
2075
				break;
-
 
2076
			case 2:
-
 
2077
				c = (d1 >= d2);
-
 
2078
				break;
-
 
2079
			case 3:
-
 
2080
				c = (d1 < d2);
-
 
2081
				break;
-
 
2082
			case 4:
-
 
2083
				c = (d1 <= d2);
-
 
2084
				break;
-
 
2085
			case 5:
-
 
2086
				c = (d1 == d2);
-
 
2087
				break;
-
 
2088
			case 6:
-
 
2089
				c = (d1 != d2);
-
 
2090
				break;
-
 
2091
			}
-
 
2092
			break;
-
 
2093
		} else {
-
 
2094
			unsigned int d1 = (unsigned int)c1;
-
 
2095
			unsigned int d2 = (unsigned int)c2;
-
 
2096
			switch (test_no)EXHAUSTIVE {
-
 
2097
			case 1:
-
 
2098
				c = (d1 > d2);
-
 
2099
				break;
-
 
2100
			case 2:
-
 
2101
				c = (d1 >= d2);
-
 
2102
				break;
-
 
2103
			case 3:
-
 
2104
				c = (d1 < d2);
-
 
2105
				break;
-
 
2106
			case 4:
-
 
2107
				c = (d1 <= d2);
-
 
2108
				break;
-
 
2109
			case 5:
-
 
2110
				c = (d1 == d2);
-
 
2111
				break;
-
 
2112
			case 6:
-
 
2113
				c = (d1 != d2);
-
 
2114
				break;
-
 
2115
			}
-
 
2116
			break;
-
 
2117
		}
-
 
2118
	}
-
 
2119
	return(c);
-
 
2120
}
-
 
2121
 
-
 
2122
 
-
 
2123
int
-
 
2124
docmp_f(int test_no, exp a, exp b)
-
 
2125
{
-
 
2126
	shape sha = sh(a);
-
 
2127
	flt64 xa, xb;
-
 
2128
	int sg = is_signed(sha);
-
 
2129
	int eq = 0;
-
 
2130
	int less = 0;
-
 
2131
	int gr = 0;
-
 
2132
	int c;
-
 
2133
 
-
 
2134
	if (shape_size(sh(a)) <= 32) {
-
 
2135
		return docmp(sha, (unsigned char)test_no, no(a), no(b));
-
 
2136
	}
-
 
2137
 
-
 
2138
	xa = exp_to_f64(a);
-
 
2139
	xb = exp_to_f64(b);
-
 
2140
 
-
 
2141
	if (xa.big == xb.big && xa.small == xb.small) {
-
 
2142
		eq = 1;
-
 
2143
	}
-
 
2144
 
-
 
2145
	if (sg && !eq) {
-
 
2146
		if (xa.big < xb.big) {
-
 
2147
			less = 1;
-
 
2148
		} else if (xa.big > xb.big) {
-
 
2149
			gr = 1;
-
 
2150
		} else {
-
 
2151
			if (xa.small < xb.small) {
-
 
2152
				less = 1;
-
 
2153
			} else {
-
 
2154
				gr = 1;
-
 
2155
			}
-
 
2156
		}
-
 
2157
	} else if (!eq) {
-
 
2158
		if ((unsigned int)xa.big < (unsigned int)xb.big) {
-
 
2159
			less = 1;
-
 
2160
		} else if ((unsigned int)xa.big > (unsigned int)xb.big) {
-
 
2161
			gr = 1;
-
 
2162
		} else {
-
 
2163
			if (xa.small < xb.small) {
-
 
2164
				less = 1;
-
 
2165
			} else {
-
 
2166
				gr = 1;
-
 
2167
			}
-
 
2168
		}
-
 
2169
	}
-
 
2170
 
-
 
2171
	switch (test_no)EXHAUSTIVE {
-
 
2172
	case 1:
-
 
2173
		c = gr;
-
 
2174
		break;
-
 
2175
	case 2:
-
 
2176
		c = gr | eq;
-
 
2177
		break;
-
 
2178
	case 3:
-
 
2179
		c = less;
-
 
2180
		break;
-
 
2181
	case 4:
-
 
2182
		c = less | eq;
-
 
2183
		break;
-
 
2184
	case 5:
-
 
2185
		c = eq;
-
 
2186
		break;
-
 
2187
	case 6:
-
 
2188
		c = !eq;
-
 
2189
		break;
-
 
2190
	}
-
 
2191
	return c;
-
 
2192
}
2110
 
2193
 
-
 
2194
 
2111
/* main bottom-to-top optimise routine
2195
/* main bottom-to-top optimise routine Optimises e. No change propagates
2112
   Optimises e. No change propagates
-
 
2113
   outside scope */
2196
   outside scope */
2114
int check
-
 
2115
    PROTO_N ( (e, scope) )
-
 
2116
    PROTO_T ( exp e X exp scope )
-
 
2117
{
-
 
2118
  if (is_a (name (e))) {/* main op non-side effect */
-
 
2119
    unsigned char n = name(e);
-
 
2120
    if (son(e) != nilexp && n != name_tag && n != env_offset_tag &&
-
 
2121
	n != general_env_offset_tag &&
-
 
2122
	n != proc_tag && n != general_proc_tag) {
-
 
2123
      exp temp = son(e);
-
 
2124
      while (1) {
-
 
2125
        if (name(sh(temp)) == bothd) {
-
 
2126
		/* unordered; temp can be first, iwc all siblings unreachable */
-
 
2127
#ifdef NEWDIAGS
-
 
2128
	  if (diagnose) {
-
 
2129
	    exp sib = son(e);
-
 
2130
	    for (;;) {
-
 
2131
	      if (sib != temp)
-
 
2132
		dg_dead_code (sib, temp);
-
 
2133
	      if (last(sib))
-
 
2134
		break;
-
 
2135
	      sib = bro(sib);
-
 
2136
	    }
-
 
2137
	    dg_whole_comp (e, temp);
-
 
2138
	  }
-
 
2139
#endif
-
 
2140
	  replace(e, temp, scope);
-
 
2141
	  retcell(e);
-
 
2142
	  return 1;
-
 
2143
        };
-
 
2144
        if (last(temp))
-
 
2145
	  break;
-
 
2146
        temp = bro(temp);
-
 
2147
      }
-
 
2148
    }
-
 
2149
 
-
 
2150
    switch (name (e)) {
-
 
2151
      case component_tag:
-
 
2152
        {
-
 
2153
          exp v = son(e);
-
 
2154
          exp a = bro(v);
-
 
2155
 
-
 
2156
          if (name(a) == val_tag)
-
 
2157
            {
-
 
2158
             exp res;
-
 
2159
             if (no(a) == 0 && shape_size(sh(v)) == shape_size(sh(e))
-
 
2160
#if dont_unpad_apply
-
 
2161
                     && name(v) != apply_tag
-
 
2162
#endif
-
 
2163
                            ) { /* remove the operation if the offset
-
 
2164
                                     is zero and the size is the same.
-
 
2165
                                     This typically happens in selecting
-
 
2166
                                     from a union if the component has
-
 
2167
                                     the maximum size in the union */
-
 
2168
                 sh(v) = sh(e);
-
 
2169
#ifdef NEWDIAGS
-
 
2170
		 if (diagnose)
-
 
2171
		   dg_whole_comp (e, v);
-
 
2172
#endif
-
 
2173
                 replace(e, v, scope);
-
 
2174
                 retcell(a);
-
 
2175
                 retcell(e);
-
 
2176
                 return 1;
-
 
2177
               };
-
 
2178
 
2197
 
2296
#ifdef NEWDIAGS
2392
#ifdef NEWDIAGS
2297
	    if (diagnose)
2393
					if (diagnose) {
2298
	      dg_whole_comp (e, son(e));
2394
						dg_whole_comp(e, son(e));
-
 
2395
					}
2299
#endif
2396
#endif
2300
	    replace (e, son (e), scope);
2397
					replace(e, son(e), scope);
2301
	    retcell (e);
2398
					retcell(e);
2302
	    return (1);
2399
					return(1);
2303
	  };
2400
				};
2304
	  return 0;
2401
				return 0;
2305
	};
2402
 
2306
      case offset_max_tag:
2403
		case offset_max_tag:
2307
	{
-
 
2308
	  if (name (son (e)) == val_tag &&
2404
				if (name(son(e)) == val_tag &&
2309
	      name (bro (son (e))) == val_tag &&
2405
				    name(bro(son(e))) == val_tag &&
-
 
2406
				    !isbigval(son(e)) &&
2310
		!isbigval(son(e)) && !isbigval(bro(son(e)))) {
2407
				    !isbigval(bro(son(e)))) {
2311
	    /* both arguments constant */
2408
					/* both arguments constant */
2312
            int n1 = no(son(e));
2409
					int n1 = no(son(e));
2313
            int n2 = no(bro(son(e)));
2410
					int n2 = no(bro(son(e)));
2314
	    no (son (e)) = (n1 > n2) ? n1 : n2;
2411
					no(son(e)) = (n1 > n2)? n1 : n2;
2315
	    sh (son (e)) = sh (e);
2412
					sh(son(e)) = sh(e);
2316
	    retcell (bro (son (e)));
2413
					retcell(bro(son(e)));
2317
	    replace (e, son (e), scope);
2414
					replace(e, son(e), scope);
2318
	    retcell (e);
2415
					retcell(e);
2319
	    return (1);
2416
					return(1);
2320
	  };
2417
				}
2321
	  return 0;
2418
				return 0;
2322
	};
2419
 
2323
      case offset_mult_tag:
2420
		case offset_mult_tag:
2324
	{
-
 
2325
	  if (name (son (e)) == val_tag &&
2421
				if (name(son(e)) == val_tag &&
2326
	      name (bro (son (e))) == val_tag &&
2422
				    name(bro(son(e))) == val_tag &&
-
 
2423
				    !isbigval(son(e)) &&
2327
		!isbigval(son(e)) && !isbigval(bro(son(e)))) {
2424
				    !isbigval(bro(son(e)))) {
2328
	    /* both arguments constant */
2425
					/* both arguments constant */
2329
            int n1 = no(son(e));
2426
					int n1 = no(son(e));
2330
            int n2 = no(bro(son(e)));
2427
					int n2 = no(bro(son(e)));
2331
	    no (son (e)) = n1 * n2;
2428
					no(son(e)) = n1 * n2;
2332
	    sh (son (e)) = sh (e);
2429
					sh(son(e)) = sh(e);
2333
	    retcell (bro (son (e)));
2430
					retcell(bro(son(e)));
2334
	    replace (e, son (e), scope);
2431
					replace(e, son(e), scope);
2335
	    retcell (e);
2432
					retcell(e);
2336
	    return (1);
2433
					return(1);
2337
	  };
2434
				}
2338
          if (name(son(e)) == val_tag && !isbigval(son(e))&&
2435
				if (name(son(e)) == val_tag &&
-
 
2436
				    !isbigval(son(e)) &&
2339
		 no(son(e)) == 1)
2437
				    no(son(e)) == 1) {
2340
            {  /* multiply by 1 */
2438
					/* multiply by 1 */
2341
              sh(bro(son(e))) = sh(e);
2439
					sh(bro(son(e))) = sh(e);
2342
              replace(e, bro(son(e)), scope);
2440
					replace(e, bro(son(e)), scope);
2343
              retcell(e);
2441
					retcell(e);
2344
              return (1);
2442
					return(1);
2345
            };
2443
				}
-
 
2444
				if (name(son(e)) == val_tag &&
2346
          if (name(son(e)) == val_tag && !isbigval(son(e)) &&					no(son(e)) == 0)
2445
				    !isbigval(son(e)) && no(son(e)) == 0) {
2347
            {  /* multiply by 0 - replace by sequence - side-effects!*/
2446
					/* multiply by 0 - replace by sequence
-
 
2447
					 * - side-effects!*/
2348
	      exp_list el;
2448
					exp_list el;
2349
	      el.start = bro(son(e));
2449
					el.start = bro(son(e));
2350
	      el.end = bro(son(e));
2450
					el.end = bro(son(e));
2351
	      el.number = 1;
2451
					el.number = 1;
2352
              sh(son(e)) = sh(e);
2452
					sh(son(e)) = sh(e);
2353
              replace(e, f_sequence(el, son(e)), scope);
2453
					replace(e, f_sequence(el, son(e)),
-
 
2454
						scope);
2354
              retcell(e);
2455
					retcell(e);
2355
              return (1);
2456
					return(1);
-
 
2457
				}
-
 
2458
 
-
 
2459
				if (name(bro(son(e))) == val_tag &&
-
 
2460
				    name(son(e)) == plus_tag) {
-
 
2461
					/* distribute offset_mult over plus
-
 
2462
					 * (giving offset_adds) */
-
 
2463
					/* the plus operation */
-
 
2464
					exp pl = son(e);
-
 
2465
 
-
 
2466
					/* the offset constant */
-
 
2467
					exp b = bro(pl);
-
 
2468
 
-
 
2469
					/* the first plus operand */
-
 
2470
					exp x = son(pl);
-
 
2471
 
-
 
2472
					exp bx = bro(x);
-
 
2473
					exp res = hold_check(me_b3(sh(e), x,
-
 
2474
						  copy(b), offset_mult_tag));
-
 
2475
					exp temp;
-
 
2476
					while (bx != pl) {
2356
            };
2477
						x = bx;
-
 
2478
						bx = bro(x);
-
 
2479
						temp = hold_check(me_b3(sh(e),
-
 
2480
							x, copy(b),
-
 
2481
							offset_mult_tag));
-
 
2482
						res = hold_check(me_b3(sh(e),
-
 
2483
							res, temp,
-
 
2484
							offset_add_tag));
-
 
2485
					}
-
 
2486
					retcell(b);
-
 
2487
					replace(e, res, scope);
-
 
2488
					retcell(e);
-
 
2489
					return 1;
-
 
2490
				}
-
 
2491
				return 0;
-
 
2492
 
-
 
2493
		case offset_div_by_int_tag:
-
 
2494
		case offset_div_tag:
-
 
2495
				if (name(son(e)) == val_tag &&
-
 
2496
				    name(bro(son(e))) == val_tag &&
-
 
2497
				    !isbigval(son(e)) &&
-
 
2498
				    !isbigval(bro(son(e)))) {
-
 
2499
					/* both arguments constant */
-
 
2500
					int n1 = no(son(e));
-
 
2501
					int n2 = no(bro(son(e)));
-
 
2502
					no(son(e)) = n1 / n2;
-
 
2503
					sh(son(e)) = sh(e);
-
 
2504
					retcell(bro(son(e)));
-
 
2505
					replace(e, son(e), scope);
-
 
2506
					retcell(e);
-
 
2507
					return(1);
-
 
2508
				}
-
 
2509
				return 0;
2357
 
2510
 
2358
          if (name(bro(son(e))) == val_tag &&
-
 
2359
               name(son(e)) == plus_tag)
-
 
2360
            {  /* distribute offset_mult over plus (giving
-
 
2361
                  offset_adds) */
-
 
2362
              exp pl = son(e);  /* the plus operation */
-
 
2363
              exp b = bro(pl);  /* the offset constant */
-
 
2364
              exp x = son(pl);  /* the first plus operand */
-
 
2365
	      exp bx = bro(x);
-
 
2366
              exp res = hold_check(me_b3(sh(e), x, copy(b),
-
 
2367
					 offset_mult_tag));
-
 
2368
	      exp temp;
-
 
2369
	      while (bx != pl) {
-
 
2370
		x = bx;
-
 
2371
	        bx = bro(x);
-
 
2372
		temp = hold_check(me_b3(sh(e), x, copy(b),
-
 
2373
					 offset_mult_tag));
-
 
2374
		res = hold_check(me_b3(sh(e), res, temp, offset_add_tag));
-
 
2375
	      };
-
 
2376
	      retcell(b);
-
 
2377
              replace(e, res, scope);
-
 
2378
              retcell(e);
-
 
2379
              return 1;
-
 
2380
            };
-
 
2381
	  return 0;
-
 
2382
	};
-
 
2383
      case offset_div_by_int_tag:
-
 
2384
      case offset_div_tag:
-
 
2385
	{
-
 
2386
	  if (name (son (e)) == val_tag &&
-
 
2387
	      name (bro (son (e))) == val_tag &&
-
 
2388
		!isbigval(son(e)) && !isbigval(bro(son(e)))) {
-
 
2389
	    /* both arguments constant */
-
 
2390
            int n1 = no(son(e));
-
 
2391
            int n2 = no(bro(son(e)));
-
 
2392
	    no (son (e)) = n1 / n2;
-
 
2393
	    sh (son (e)) = sh (e);
-
 
2394
	    retcell (bro (son (e)));
-
 
2395
	    replace (e, son (e), scope);
-
 
2396
	    retcell (e);
-
 
2397
	    return (1);
-
 
2398
	  };
-
 
2399
	  return 0;
-
 
2400
	};
-
 
2401
#if has_setcc
2511
#if has_setcc
2553
#if isAlpha
2673
#if isAlpha
2554
	{ exp ptr = son(e);
2674
				{ exp ptr = son(e);
2555
	  exp off = bro(ptr);
2675
					exp off = bro(ptr);
2556
	  if ((al1_of(sh(off))->al.al_val.al_frame & 4) != 0 &&
2676
					if ((al1_of(sh(off))->al.al_val.al_frame & 4) != 0 &&
2557
		!is_floating(al2_of(sh(off))->al.sh_hd)) {
2677
					    !is_floating(al2_of(sh(off))->al.sh_hd)) {
2558
		exp r = getexp (sh(ptr), off, 0, ptr, nilexp,
2678
						exp r = getexp(sh(ptr), off, 0,
-
 
2679
							       ptr, nilexp, 0,
2559
				0, 6*64, reff_tag);
2680
							       6*64, reff_tag);
-
 
2681
						sh(off) =
-
 
2682
						    f_offset(al1_of(sh(off)),
2560
		sh(off) = f_offset(al1_of(sh(off)), long_to_al(al2(sh(off))));
2683
						    long_to_al(al2(sh(off))));
-
 
2684
						bro(ptr) =r;
2561
		bro(ptr)=r; setlast(ptr);
2685
						setlast(ptr);
2562
		son(e) = r;
2686
						son(e) = r;
2563
	  }
2687
					}
2564
	}
2688
				}
2565
 
2689
 
2566
#endif
2690
#endif
2567
	  if (name (bro (son (e))) == val_tag &&
2691
				if (name(bro(son(e))) == val_tag &&
2568
		 !isbigval(bro (son (e)))) {
2692
				    !isbigval(bro(son(e)))) {
2569
	    /* replace addptr(x, const) by refffield operation */
2693
					/* replace addptr(x, const) by
-
 
2694
					 * refffield operation */
2570
	    exp p = son (e);
2695
					exp p = son(e);
2571
	    int  k = no (bro (p));
2696
					int k = no(bro(p));
2572
	    exp r;
2697
					exp r;
2573
	    r = getexp (sh (e), nilexp, 0, p, nilexp,
2698
					r = getexp(sh(e), nilexp, 0, p, nilexp,
2574
		0, k, reff_tag);
2699
						   0, k, reff_tag);
2575
#ifdef NEWDIAGS
2700
#ifdef NEWDIAGS
2576
	    dgf(r) = dgf(e);
2701
					dgf(r) = dgf(e);
2577
#endif
2702
#endif
2578
	    replace (e, hc (r, p), scope);
2703
					replace(e, hc(r, p), scope);
2579
	    retcell (e);
2704
					retcell(e);
2580
	    return (1);
2705
					return(1);
2581
	  };
2706
				}
2582
	  if (name (son (e)) == reff_tag &&
2707
				if (name(son(e)) == reff_tag &&
2583
                shape_size(sh(e)) == 32) {
2708
				    shape_size(sh(e)) == 32) {
2584
	    /* replace addptr(reff[n](a), b) by reff[n](addptr(a, b)) */
2709
					/* replace addptr(reff[n](a), b) by
-
 
2710
					 * reff[n](addptr(a, b)) */
2585
	    exp p = son (son (e));
2711
					exp p = son(son(e));
2586
	    exp a = bro (son (e));
2712
					exp a = bro(son(e));
2587
	    exp ap1 = getexp (sh (e), nilexp, 0, p, nilexp,
2713
					exp ap1 = getexp(sh(e), nilexp, 0, p,
-
 
2714
							 nilexp, 0, 0,
2588
		0, 0, addptr_tag);
2715
							 addptr_tag);
2589
	    exp ap, r;
2716
					exp ap, r;
2590
	    bro (p) = a;
2717
					bro(p) = a;
2591
	    clearlast (p);
2718
					clearlast(p);
2592
#if NEWDIAGS
-
 
2593
	    if (diagnose)
-
 
2594
	      dg_whole_comp (son(e), p);
-
 
2595
#endif
-
 
2596
	    ap = hc (ap1, a);
-
 
2597
	    r = hc (getexp (sh (e), nilexp, 0, ap, nilexp,
-
 
2598
			0, no (son (e)), reff_tag),
-
 
2599
		   ap);
-
 
2600
#if NEWDIAGS
2719
#if NEWDIAGS
2601
	    if (diagnose)
2720
					if (diagnose) {
2602
	      dg_whole_comp (e, r);
2721
						dg_whole_comp(son(e), p);
-
 
2722
					}
2603
#endif
2723
#endif
2604
	    replace (e, r, scope);
-
 
2605
	    retcell (son (e));
-
 
2606
	    retcell (e);
2724
					ap = hc(ap1, a);
2607
	    return (1);
-
 
2608
	  };
-
 
2609
          if (name(bro(son(e))) == offset_add_tag)
2725
					r = hc(getexp(sh(e), nilexp, 0, ap,
2610
           {
-
 
2611
             exp p = son(e);
2726
						      nilexp, 0, no(son(e)),
2612
             exp a = son(bro(p));
-
 
2613
             exp c = bro(a);
-
 
2614
             if (name(c) == val_tag && !isbigval(c)) {
-
 
2615
               exp ap =
-
 
2616
                 hold_check(me_b3(f_pointer(long_to_al(al2(sh(a)))),
-
 
2617
                                   p, a, addptr_tag));
-
 
2618
               exp r = getexp(sh(e), nilexp, 0, ap, nilexp, 0,
-
 
2619
                             no(c), reff_tag);
-
 
2620
               setfather(r, ap);
2727
						      reff_tag), ap);
2621
#ifdef NEWDIAGS
-
 
2622
	       dgf(r) = dgf(e);
-
 
2623
#endif
-
 
2624
               replace(e, hold_check(r), scope);
-
 
2625
               retcell(e);
-
 
2626
               return 1;
-
 
2627
	     };
-
 
2628
	     if (al1(sh(p)) == al2(sh(c)))  {
-
 
2629
	       exp inner, outer;
-
 
2630
	       inner = hold_check(me_b3(sh(e), p, a, addptr_tag));
-
 
2631
#ifdef NEWDIAGS
-
 
2632
	       if (diagnose)
-
 
2633
		 dg_whole_comp (bro(p), inner);
-
 
2634
#endif
-
 
2635
	       outer = hold_check(me_b3(sh(e), inner, c, addptr_tag));
-
 
2636
#ifdef NEWDIAGS
2728
#if NEWDIAGS
2637
	       if (diagnose)
2729
					if (diagnose) {
2638
		 dg_whole_comp (e, outer);
2730
						dg_whole_comp(e, r);
2639
			/* also represent movement of c !!!!!!!!!!!!!!!!!!!!!!!!! */
-
 
2640
#endif
-
 
2641
	       replace(e, outer, scope);
-
 
2642
	       retcell(e);
-
 
2643
	       return 1;
-
 
2644
	     };
-
 
2645
           };
-
 
2646
	  return 0;
-
 
2647
	};
-
 
2648
      case chvar_tag: {
-
 
2649
#ifdef value_of_null
-
 
2650
	  if (name(son(e))==null_tag) {
-
 
2651
	    setname(son(e), val_tag);
-
 
2652
	    no(son(e))= value_of_null;
-
 
2653
	    clearbigval(son(e));
-
 
2654
	    sh (son (e)) = sh(e);
-
 
2655
#ifdef NEWDIAGS
-
 
2656
 	    if (diagnose)
-
 
2657
	      dg_whole_comp (e, son(e));
-
 
2658
#endif
-
 
2659
	    replace (e, son (e), scope);
-
 
2660
	    retcell (e);
-
 
2661
	    return (1);
-
 
2662
	  };
2731
					}
2663
#endif
-
 
2664
	  if (name (son (e)) == val_tag && optop(e)) {
-
 
2665
	    /* evaluate chvar(const) */
-
 
2666
	    int bg;
-
 
2667
	    flt64 x;
-
 
2668
	    shape sha = sh(e);
-
 
2669
	    x = exp_to_f64(son(e));
-
 
2670
/*
-
 
2671
#if has64bits
-
 
2672
  int sg = is_signed(sha);
-
 
2673
  if (extra_checks && sg && !in_proc_def &&
-
 
2674
	shape_size(sha) <= 32 && check_size(x, sg, 32)) {
-
 
2675
    failer("Change_variety out of range");
-
 
2676
    exit(EXIT_FAILURE);
-
 
2677
  };
-
 
2678
#endif
2732
#endif
-
 
2733
					replace(e, r, scope);
-
 
2734
					retcell(son(e));
-
 
2735
					retcell(e);
-
 
2736
					return(1);
2679
*/
2737
				}
-
 
2738
				if (name(bro(son(e))) == offset_add_tag) {
-
 
2739
					exp p = son(e);
-
 
2740
					exp a = son(bro(p));
-
 
2741
					exp c = bro(a);
-
 
2742
					if (name(c) == val_tag &&
-
 
2743
					    !isbigval(c)) {
-
 
2744
						exp ap = hold_check(me_b3(f_pointer(long_to_al(al2(sh(a)))),
-
 
2745
							 p, a, addptr_tag));
-
 
2746
						exp r = getexp(sh(e), nilexp, 0,
-
 
2747
							       ap, nilexp, 0,
-
 
2748
							       no(c), reff_tag);
2680
	    dochvar_f (&x, sha);
2749
						setfather(r, ap);
-
 
2750
#ifdef NEWDIAGS
-
 
2751
						dgf(r) = dgf(e);
-
 
2752
#endif
-
 
2753
						replace(e, hold_check(r),
-
 
2754
							scope);
-
 
2755
						retcell(e);
-
 
2756
						return 1;
-
 
2757
					}
-
 
2758
					if (al1(sh(p)) == al2(sh(c))) {
-
 
2759
						exp inner, outer;
2681
	    no(son(e)) = f64_to_flpt(x, is_signed(sha), &bg,
2760
						inner = hold_check(me_b3(sh(e),
2682
					 shape_size(sha));
2761
							p, a, addptr_tag));
-
 
2762
#ifdef NEWDIAGS
2683
	    if (bg)
2763
						if (diagnose) {
-
 
2764
							dg_whole_comp(bro(p),
-
 
2765
								      inner);
-
 
2766
						}
-
 
2767
#endif
-
 
2768
						outer = hold_check(me_b3(sh(e),
-
 
2769
							inner, c, addptr_tag));
-
 
2770
#ifdef NEWDIAGS
2684
	      setbigval(son(e));
2771
						if (diagnose) {
-
 
2772
							dg_whole_comp(e, outer);
2685
	    else
2773
						}
-
 
2774
						/* also represent movement of
-
 
2775
						 * c! */
-
 
2776
#endif
-
 
2777
						replace(e, outer, scope);
-
 
2778
						retcell(e);
-
 
2779
						return 1;
-
 
2780
					}
-
 
2781
				}
-
 
2782
				return 0;
-
 
2783
 
-
 
2784
		case chvar_tag:
-
 
2785
#ifdef value_of_null
-
 
2786
			if (name(son(e)) ==null_tag) {
-
 
2787
				setname(son(e), val_tag);
-
 
2788
				no(son(e)) = value_of_null;
2686
	      clearbigval(son(e));
2789
				clearbigval(son(e));
2687
	    sh (son (e)) = sha;
2790
				sh(son(e)) = sh(e);
2688
#ifdef NEWDIAGS
2791
#ifdef NEWDIAGS
2689
 	    if (diagnose)
2792
				if (diagnose) {
2690
	      dg_whole_comp (e, son(e));
2793
					dg_whole_comp(e, son(e));
-
 
2794
				}
2691
#endif
2795
#endif
2692
	    replace (e, son (e), scope);
2796
				replace(e, son(e), scope);
2693
	    retcell (e);
2797
				retcell(e);
2694
	    return (1);
2798
				return(1);
2695
	  };
2799
			}
-
 
2800
#endif
2696
	  if (eq_shape (sh (e),  sh (son (e)))) {
2801
			if (name(son(e)) == val_tag && optop(e)) {
2697
	    /* replace identity chvar by argument */
2802
				/* evaluate chvar(const) */
-
 
2803
				int bg;
-
 
2804
				flt64 x;
-
 
2805
				shape sha = sh(e);
-
 
2806
				x = exp_to_f64(son(e));
-
 
2807
				/*
-
 
2808
#if has64bits
-
 
2809
				int sg = is_signed(sha);
-
 
2810
				if (extra_checks && sg && !in_proc_def &&
-
 
2811
				    shape_size(sha) <= 32 &&
-
 
2812
				    check_size(x, sg, 32)) {
-
 
2813
					failer("Change_variety out of range");
-
 
2814
					exit(EXIT_FAILURE);
-
 
2815
				}
-
 
2816
#endif
-
 
2817
				 */
-
 
2818
				dochvar_f(&x, sha);
-
 
2819
				no(son(e)) = f64_to_flpt(x, is_signed(sha), &bg,
-
 
2820
							 shape_size(sha));
-
 
2821
				if (bg) {
-
 
2822
					setbigval(son(e));
-
 
2823
				} else {
-
 
2824
					clearbigval(son(e));
-
 
2825
				}
-
 
2826
				sh(son(e)) = sha;
2698
#ifdef NEWDIAGS
2827
#ifdef NEWDIAGS
2699
 	    if (diagnose)
2828
				if (diagnose)
2700
	      dg_whole_comp (e, son(e));
2829
					dg_whole_comp(e, son(e));
2701
#endif
2830
#endif
2702
	    replace (e, son (e), scope);
2831
				replace(e, son(e), scope);
-
 
2832
				retcell(e);
-
 
2833
				return(1);
-
 
2834
			}
-
 
2835
			if (eq_shape(sh(e), sh(son(e)))) {
-
 
2836
				/* replace identity chvar by argument */
-
 
2837
#ifdef NEWDIAGS
-
 
2838
				if (diagnose) {
-
 
2839
					dg_whole_comp(e, son(e));
-
 
2840
				}
-
 
2841
#endif
-
 
2842
				replace(e, son(e), scope);
2703
	    retcell (e);
2843
				retcell(e);
2704
	    return (1);
2844
				return(1);
2705
	  };
2845
			}
2706
	  if (name(son(e)) == chvar_tag &&
2846
			if (name(son(e)) == chvar_tag &&
-
 
2847
					shape_size(sh(e)) ==
2707
		 shape_size(sh(e)) == shape_size(sh(son(son(e)))) &&
2848
					shape_size(sh(son(son(e)))) &&
2708
		 name(sh(son(e))) == bitfhd) {
2849
					name(sh(son(e))) == bitfhd) {
2709
	    exp res = hold_check(me_u3(sh(e), son(son(e)), chvar_tag));
2850
				exp res = hold_check(me_u3(sh(e),
-
 
2851
							son(son(e)),
-
 
2852
							chvar_tag));
2710
	    replace(e, res, scope);
2853
				replace(e, res, scope);
2711
	    retcell(e);
2854
				retcell(e);
2712
	    return 1;
2855
				return 1;
2713
	  };
2856
			}
2714
	  if (name(son(e)) == chvar_tag && !is_signed(sh(e)) &&
2857
			if (name(son(e)) == chvar_tag &&
-
 
2858
					!is_signed(sh(e)) &&
-
 
2859
					shape_size(sh(e)) ==
2715
		shape_size(sh(e)) == shape_size(sh(son(e)))) {
2860
					shape_size(sh(son(e)))) {
2716
	    replace(e, hold_check(me_u3(sh(e), son(son(e)), chvar_tag)),
2861
				replace(e, hold_check(me_u3(sh(e),
2717
			scope);
2862
								son(son(e)), chvar_tag)), scope);
2718
	    retcell(e);
2863
				retcell(e);
2719
	    return 1;
2864
				return 1;
2720
	  };
2865
			}
2721
	  if (name(son(e)) == chvar_tag && !is_signed(sh(e)) &&
2866
			if (name(son(e)) == chvar_tag &&
-
 
2867
					!is_signed(sh(e)) &&
-
 
2868
					shape_size(sh(e)) <
2722
		shape_size(sh(e)) < shape_size(sh(son(e))) &&
2869
					shape_size(sh(son(e))) &&
-
 
2870
					shape_size(sh(e)) ==
2723
		shape_size(sh(e)) == shape_size(sh(son(son(e))))) {
2871
					shape_size(sh(son(son(e))))) {
2724
	    replace(e, hold_check(me_u3(sh(e), son(son(e)), chvar_tag)),
2872
				replace(e, hold_check(me_u3(sh(e),
-
 
2873
								son(son(e)), chvar_tag)),
2725
			scope);
2874
						scope);
2726
	    retcell(e);
2875
				retcell(e);
2727
	    return 1;
2876
				return 1;
2728
	  };
2877
			}
2729
#if little_end & has_byte_regs
2878
#if little_end & has_byte_regs
2730
	  /* only for little enders which have byte registers */
2879
			/* only for little enders which have byte
-
 
2880
			 * registers */
-
 
2881
			if ((shape_size(sh(e)) <=
2731
	  if ((shape_size(sh(e)) <= shape_size(sh(son(e)))) && optop(e) &&
2882
						shape_size(sh(son(e)))) && optop(e) &&
2732
	      (name (son (e)) == name_tag ||
2883
					(name(son(e)) == name_tag ||
2733
		name (son (e)) == cont_tag ||
2884
					 name(son(e)) == cont_tag ||
2734
		name (son (e)) == cond_tag
2885
					 name(son(e)) == cond_tag)) {
2735
	      )) {
2886
				/* if the chvar operation never needs
2736
	    /* if the chvar operation never needs any action for a little
2887
				 * any action for a little end machine,
2737
	       end machine, eliminate it */
2888
				 * eliminate it */
2738
#if is80x86
2889
#if is80x86
2739
	    if (shape_size(sh(e)) == 8) {
2890
				if (shape_size(sh(e)) == 8) {
2740
	      if (name (son (e)) == name_tag)
2891
					if (name(son(e)) == name_tag) {
2741
		setvis(son(son(e)));
2892
						setvis(son(son(e)));
-
 
2893
					}
2742
	      if (name (son (e)) == cont_tag &&
2894
					if (name(son(e)) == cont_tag &&
2743
			name(son(son(e))) == name_tag )
2895
							name(son(son(e))) ==
-
 
2896
							name_tag) {
2744
		setvis(son(son(son(e))));
2897
						setvis(son(son(son(e))));
2745
	    };
2898
					}
-
 
2899
				}
2746
#endif
2900
#endif
2747
	    sh (son (e)) = sh (e);
2901
				sh(son(e)) = sh(e);
2748
	    replace (e, son (e), scope);
2902
				replace(e, son(e), scope);
2749
		/* should this retcell(e) ? */
2903
				/* should this retcell(e) ? */
2750
	    return (1);
2904
				return(1);
2751
	  };
2905
			}
2752
	  /* only for little enders which have byte registers */
2906
			/* only for little enders which have byte
-
 
2907
			 * registers */
2753
	  if (name (son (e)) == chvar_tag &&
2908
			if (name(son(e)) == chvar_tag &&
-
 
2909
					shape_size(sh(e)) <=
2754
	      shape_size(sh(e)) <= shape_size(sh (son (e)))) {
2910
					shape_size(sh(son(e)))) {
2755
	    /* if the chvar operation never needs any action for a little
2911
				/* if the chvar operation never needs
-
 
2912
				 * any action for a little end machine,
2756
	       end machine, eliminate it */
2913
				 * eliminate it */
2757
	    exp w;
2914
				exp w;
2758
	    sh (son (e)) = sh (e);
2915
				sh(son(e)) = sh(e);
2759
	    w = hold (son (e));
2916
				w = hold(son(e));
2760
	    IGNORE check (son (w), son (w));
2917
				IGNORE check(son(w), son(w));
2761
	    replace (e, son (w), scope);
2918
				replace(e, son(w), scope);
2762
	    retcell (e);
2919
				retcell(e);
2763
	    retcell (w);
2920
				retcell(w);
2764
	    return (1);
2921
				return(1);
2765
	  };
2922
			}
2766
#endif
2923
#endif
2767
#if little_end & has_byte_ops
2924
#if little_end & has_byte_ops
2768
	  /* only for little enders with byte and short operations */
2925
			/* only for little enders with byte and short
-
 
2926
			 * operations */
-
 
2927
			if (shape_size(sh(e)) <=
2769
	  if (shape_size(sh(e)) <= shape_size(sh (son (e))) && optop(e) &&
2928
					shape_size(sh(son(e))) && optop(e) &&
2770
		name(sh(e)) != bitfhd &&
2929
					name(sh(e)) != bitfhd &&
2771
	       (name (son (e)) == plus_tag ||
2930
					(name(son(e)) == plus_tag ||
2772
		name (son (e)) == minus_tag ||
2931
					 name(son(e)) == minus_tag ||
2773
		name (son (e)) == and_tag ||
2932
					 name(son(e)) == and_tag ||
2774
		name (son (e)) == or_tag ||
2933
					 name(son(e)) == or_tag ||
2775
		name (son (e)) == neg_tag
2934
					 name(son(e)) == neg_tag)) {
2776
	      )
-
 
2777
	    ) {
2935
				/* replace chvar(op(a ...)) by
2778
	    /* replace chvar(op(a ...)) by op(chvar(a)...) if the
2936
				 * op(chvar(a)...) if the changevar
2779
	       changevar requires no action on a little end machine */
2937
				 * requires no action on a little end
-
 
2938
				 * machine */
2780
#if only_lengthen_ops
2939
#if only_lengthen_ops
2781
	      exp p = son (e);
2940
				exp p = son(e);
2782
	      exp r;
2941
				exp r;
2783
	      exp a = son (p);
2942
				exp a = son(p);
2784
	      exp n = bro (a);
2943
				exp n = bro(a);
2785
	      int l = (int)last (a);
2944
				int l = (int)last(a);
2786
 
2945
 
2787
/*
-
 
2788
	      if (shape_size(sh(e)) >= 16)
2946
				/* if (shape_size(sh(e)) >= 16) */
2789
*/
-
 
2790
	  /* this is to avoid allocating bytes to edi/esi in 80386 !!! bad
2947
				/* this is to avoid allocating bytes to
2791
	  */
-
 
2792
#endif
-
 
2793
	    {
-
 
2794
	      exp sha = sh (e);
-
 
2795
	      exp t = varchange (sha, a);
2948
				 * edi/esi in 80386 !!! bad
2796
	      exp q = t;
-
 
2797
 
-
 
2798
	      while (!l) {
-
 
2799
	        l = (int)last (n);
-
 
2800
	        a = n;
-
 
2801
	        n = bro (n);
-
 
2802
	        setbro (q, varchange (sha, a));
-
 
2803
	        clearlast (q);
-
 
2804
	        q = bro (q);
-
 
2805
	      };
-
 
2806
 
-
 
2807
	      r = getexp (sha, nilexp, 0, t, pt (p), 0, no (p),
-
 
2808
		  name (p));
-
 
2809
              seterrhandle(r, errhandle(e));
-
 
2810
	      replace (e, hc (r, q), scope);
-
 
2811
	      retcell (e);
-
 
2812
	      return (1);
-
 
2813
	    };
2949
				 */
2814
	  };
-
 
2815
#endif
2950
#endif
2816
	  if (name (son (e)) == ident_tag && isvar (son (e))) {
-
 
2817
	    /* distribute chvar into variable declaration of simple form
-
 
2818
	    */
-
 
2819
	    exp vardec = son (e);
-
 
2820
	    exp def = son (vardec);
-
 
2821
	    exp body = bro (def);
-
 
2822
	    exp res;
-
 
2823
	    bool go = 1;
-
 
2824
	    exp t, u, v;
-
 
2825
	    if (name (body) != seq_tag)
-
 
2826
	      return (0);
-
 
2827
	    res = bro (son (body));
-
 
2828
	    if (name (res) != cont_tag || name (son (res)) != name_tag ||
-
 
2829
		son (son (res)) != vardec)
-
 
2830
	      return (0);
-
 
2831
	    t = pt (vardec);
-
 
2832
	    while (t != nilexp && go) {
-
 
2833
	      if (t == son (res) || (!last (t) &&
-
 
2834
		    name (bro (bro (t))) == ass_tag))
-
 
2835
		t = pt (t);
-
 
2836
	      else
-
 
2837
		go = 0;
-
 
2838
	    };
-
 
2839
	    if (!go)
-
 
2840
	      return (0);
-
 
2841
	    if (name(def) == clear_tag) {
-
 
2842
	      u = copy(def);
-
 
2843
	      sh(u) = sh(e);
-
 
2844
	    }
-
 
2845
	    else
-
 
2846
	      u = varchange (sh (e), copy (def));
-
 
2847
	    replace (def, u, u);
-
 
2848
	    kill_exp (def, def);
-
 
2849
	    sh (res) = sh (e);
-
 
2850
	    sh (body) = sh(e);
-
 
2851
	    t = pt (vardec);
-
 
2852
	    while (t != nilexp) {
-
 
2853
	      if (t != son (res)) {
-
 
2854
		v = bro (t);
-
 
2855
		u = varchange (sh (e), copy (v));
-
 
2856
		replace (v, u, u);
-
 
2857
		kill_exp (v, def);
-
 
2858
	      };
-
 
2859
	      t = pt (t);
-
 
2860
	    };
-
 
2861
	    sh (vardec) = sh (e);
-
 
2862
	    replace (e, vardec, scope);
-
 
2863
	    retcell (e);
-
 
2864
	    return (1);
-
 
2865
	  };
2951
				{
2866
	  return 0;
-
 
2867
	};
-
 
2868
      case bitf_to_int_tag:
-
 
2869
        {
-
 
2870
	  if (newcode) {
-
 
2871
	    exp temp = son(e);
2952
					exp sha = sh(e);
2872
	    int szbf = shape_size(sh(temp));
-
 
2873
	    shape sha;
-
 
2874
	    int sg = is_signed(sh(temp));
2953
					exp t = varchange(sha, a);
2875
	    int s;
2954
					exp q = t;
2876
 
2955
 
2877
	    if (szbf <= 8)
2956
					while (!l) {
2878
	      sha = (sg) ? scharsh : ucharsh;
-
 
2879
	    else
-
 
2880
	    if (szbf <= 16)
-
 
2881
	      sha = (sg) ? swordsh : uwordsh;
-
 
2882
	    else
-
 
2883
	    if (szbf <= 32)
2957
						l = (int)last(n);
2884
	      sha = (sg) ? slongsh : ulongsh;
-
 
2885
	    else
2958
						a = n;
2886
	      sha = (sg) ? s64sh : u64sh;
-
 
2887
 
-
 
2888
	    if (name(sh(temp)) == bitfhd && name(temp) == chvar_tag) {
-
 
2889
	      exp st = son(temp);
-
 
2890
	      int n = name(st);
2959
						n = bro(n);
2891
	      if ((n == cont_tag && szbf == shape_size(sh(st))) ||
-
 
2892
		  ( n==and_tag && name(bro(son(st)))== val_tag &&
-
 
2893
			no(bro(son(st))) == (1<<szbf)-1 ) ||
-
 
2894
		  ( n==shr_tag && name(bro(son(st)))== val_tag &&
-
 
2895
			no(bro(son(st))) == shape_size(sh(st))-szbf)  ) {
-
 
2896
		/* arises from bfcont_tag */
2960
						setbro(q, varchange(sha,
2897
	        replace(e, hold_check(me_u3(sh(e), st, chvar_tag)),
-
 
2898
		      scope);
2961
									a));
2899
	        retcell(e);
-
 
2900
	        retcell(temp);
2962
						clearlast(q);
2901
	        return 1;
2963
						q = bro(q);
2902
	      }
-
 
2903
	    };
2964
					}
2904
 
-
 
2905
 
-
 
2906
	    sh(temp) = sha;
-
 
2907
 
2965
 
2908
	    if (sg) {
-
 
2909
#if isAlpha
-
 
2910
	      s = shape_size(s64sh) - szbf;
2966
					r = getexp(sha, nilexp, 0, t,
2911
	      if (s != 0) {
2967
							pt(p), 0, no(p),
2912
		temp = hold_check(me_u3(s64sh, temp, chvar_tag));
-
 
2913
	        temp =
2968
							name(p));
2914
		    hold_check(me_b3(s64sh, temp,
-
 
2915
				 me_shint(s64sh, s), shl_tag));
2969
					seterrhandle(r, errhandle(e));
2916
	        temp =
-
 
2917
		    hold_check(me_b3(s64sh, temp,
-
 
2918
				 me_shint(s64sh, s), shr_tag));
2970
					replace(e, hc(r, q), scope);
2919
	      };
-
 
2920
#else
-
 
2921
	      s = shape_size(sha) - szbf;
-
 
2922
	      if (s != 0) {
-
 
2923
	        temp =
2971
					retcell(e);
2924
		  hold_check(me_b3(sha, temp, me_shint(sha, s),
-
 
2925
				 shl_tag));
2972
					return(1);
2926
	        temp =
-
 
2927
		    hold_check(me_b3(sha, temp, me_shint(sha, s),
-
 
2928
				 shr_tag));
2973
				}
2929
	      };
2974
			}
2930
#endif
2975
#endif
-
 
2976
			if (name(son(e)) == ident_tag &&
-
 
2977
					isvar(son(e))) {
-
 
2978
				/* distribute chvar into variable declaration of simple form
-
 
2979
				*/
-
 
2980
				exp vardec = son(e);
-
 
2981
				exp def = son(vardec);
-
 
2982
				exp body = bro(def);
-
 
2983
				exp res;
-
 
2984
				bool go = 1;
-
 
2985
				exp t, u, v;
-
 
2986
				if (name(body) != seq_tag)
-
 
2987
					return(0);
-
 
2988
				res = bro(son(body));
-
 
2989
				if (name(res) != cont_tag ||
-
 
2990
						name(son(res)) != name_tag ||
-
 
2991
						son(son(res)) != vardec)
-
 
2992
					return(0);
-
 
2993
				t = pt(vardec);
-
 
2994
				while (t != nilexp && go) {
-
 
2995
					if (t == son(res) ||
-
 
2996
							(!last(t) &&
-
 
2997
							 name(bro(bro(t))) ==
-
 
2998
							 ass_tag)) {
-
 
2999
						t = pt(t);
-
 
3000
					} else {
-
 
3001
						go = 0;
2931
	    }
3002
					}
-
 
3003
				}
-
 
3004
				if (!go) {
-
 
3005
					return(0);
-
 
3006
				}
-
 
3007
				if (name(def) == clear_tag) {
-
 
3008
					u = copy(def);
-
 
3009
					sh(u) = sh(e);
2932
	    else {
3010
				} else {
2933
	        int mask = (szbf == 32) ? -1 : (1 << szbf) - 1;
3011
					u = varchange(sh(e), copy(def));
-
 
3012
				}
-
 
3013
				replace(def, u, u);
-
 
3014
				kill_exp(def, def);
-
 
3015
				sh(res) = sh(e);
-
 
3016
				sh(body) = sh(e);
-
 
3017
				t = pt(vardec);
-
 
3018
				while (t != nilexp) {
2934
	        temp = hold_check(me_b3(sha, temp,
3019
					if (t != son(res)) {
-
 
3020
						v = bro(t);
2935
				 me_shint(sha, mask), and_tag));
3021
						u = varchange(sh(e), copy(v));
-
 
3022
						replace(v, u, u);
-
 
3023
						kill_exp(v, def);
2936
	    };
3024
					}
-
 
3025
					t = pt(t);
2937
 
3026
				}
-
 
3027
				sh(vardec) = sh(e);
2938
	    replace(e, hold_check(me_u3(sh(e), temp, chvar_tag)), scope);
3028
				replace(e, vardec, scope);
2939
	    retcell(e);
3029
				retcell(e);
2940
	    return 1;
3030
				return(1);
2941
	  };
3031
			}
2942
          return 0;
3032
			return 0;
2943
        };
3033
 
2944
      case int_to_bitf_tag:
3034
		case bitf_to_int_tag:
2945
        {
-
 
2946
	  if (newcode) {
3035
			if (newcode) {
2947
	    exp temp = son(e);
3036
				exp temp = son(e);
-
 
3037
				int szbf = shape_size(sh(temp));
-
 
3038
				shape sha;
-
 
3039
				int sg = is_signed(sh(temp));
-
 
3040
				int s;
-
 
3041
 
-
 
3042
				if (szbf <= 8) {
-
 
3043
					sha = (sg)? scharsh : ucharsh;
-
 
3044
				} else if (szbf <= 16) {
-
 
3045
					sha = (sg)? swordsh : uwordsh;
-
 
3046
				} else if (szbf <= 32) {
-
 
3047
					sha = (sg)? slongsh : ulongsh;
-
 
3048
				} else {
-
 
3049
					sha = (sg)? s64sh : u64sh;
-
 
3050
				}
-
 
3051
 
-
 
3052
				if (name(sh(temp)) == bitfhd &&
-
 
3053
				    name(temp) == chvar_tag) {
2948
	    shape sha = sh(temp);
3054
					exp st = son(temp);
-
 
3055
					int n = name(st);
-
 
3056
					if ((n == cont_tag &&
2949
	    int szbf = shape_size(sh(e));
3057
					     szbf == shape_size(sh(st))) ||
-
 
3058
					    (n == and_tag &&
-
 
3059
					     name(bro(son(st))) == val_tag &&
-
 
3060
					     no(bro(son(st))) == (1 << szbf) -1)
-
 
3061
					    || (n == shr_tag &&
-
 
3062
						name(bro(son(st))) == val_tag &&
-
 
3063
						no(bro(son(st))) ==
-
 
3064
						shape_size(sh(st)) -szbf)) {
-
 
3065
						/* arises from bfcont_tag */
-
 
3066
						replace(e,
2950
	    int sg = is_signed(sh(e));
3067
							hold_check(me_u3(sh(e),
-
 
3068
							st, chvar_tag)), scope);
-
 
3069
						retcell(e);
-
 
3070
						retcell(temp);
-
 
3071
						return 1;
-
 
3072
					}
-
 
3073
				}
2951
 
3074
 
2952
	    if (shape_size(sh(son(e))) < szbf) {
-
 
2953
 
3075
 
2954
	      if (szbf <= 32)
3076
				sh(temp) = sha;
2955
	        sha = (sg) ? slongsh : ulongsh;
-
 
2956
	      else
-
 
2957
	        sha = (sg) ? s64sh : u64sh;
-
 
2958
 
3077
 
3070
#if is80x86
3243
#if is80x86
3071
	  return (comm_ass (e, mult_tag, mult_fn,
3244
			return(comm_ass(e, mult_tag, mult_fn, 1, 1, 0, scope,
3072
		1, 1, 0, scope, 0, 0));
3245
					0, 0));
3073
#else
3246
#else
3074
	  return (comm_ass (e, mult_tag, mult_fn,
3247
			return(comm_ass(e, mult_tag, mult_fn, 1, 1, 0, scope,
3075
		1, 1, 0, scope, 1, 0));
3248
					1, 0));
3076
#endif
3249
#endif
3077
	};
3250
 
3078
      case subptr_tag: {
3251
		case subptr_tag: {
3079
	  /* replace subptr(a, b) by addptr(a, (-b)) */
3252
			/* replace subptr(a, b) by addptr(a, (-b)) */
3080
	  exp z = getexp (sh (e), nilexp, 0, bro (son (e)), nilexp,
3253
			exp z = getexp(sh(e), nilexp, 0, bro(son(e)), nilexp,
3081
	      0, 0, neg_tag);
3254
				       0, 0, neg_tag);
3082
	  exp a2 = hc (z, bro (son (e)));
3255
			exp a2 = hc(z, bro(son(e)));
3083
	  exp r = getexp (sh (e), nilexp, 0, son (e), nilexp, 0,
3256
			exp r = getexp(sh(e), nilexp, 0, son(e), nilexp, 0,
3084
	      0, addptr_tag);
3257
				       0, addptr_tag);
3085
	  bro (son (e)) = a2;
3258
			bro(son(e)) = a2;
3086
#ifdef NEWDIAGS
3259
#ifdef NEWDIAGS
3087
	  if (diagnose)
3260
			if (diagnose) {
3088
	    dgf(r) = dgf(e);
3261
				dgf(r) = dgf(e);
-
 
3262
			}
-
 
3263
#endif
-
 
3264
			replace(e, hc(r, a2), scope);
-
 
3265
			retcell(e);
-
 
3266
			return(1);
-
 
3267
		}
-
 
3268
 
-
 
3269
		case neg_tag: {
-
 
3270
			if (!optop(e)) {
-
 
3271
				return 0;
-
 
3272
			}
-
 
3273
			if (name(son(e)) == val_tag) {
-
 
3274
				/* eval for const */
-
 
3275
				neg_fn(son(e));
-
 
3276
				sh(son(e)) = sh(e);
-
 
3277
#ifdef NEWDIAGS
-
 
3278
				if (diagnose) {
-
 
3279
					dg_whole_comp(e, son(e));
-
 
3280
				}
-
 
3281
#endif
-
 
3282
				replace(e, son(e), scope);
-
 
3283
				retcell(e);
-
 
3284
				return(1);
-
 
3285
			}
-
 
3286
			if (name(son(e)) == neg_tag && optop(e) &&
-
 
3287
			    optop(son(e))) {
-
 
3288
				/* replace --a by a if errtreat is impossible
-
 
3289
				 * or ignore */
-
 
3290
				sh(son(son(e))) = sh(e);
-
 
3291
#ifdef NEWDIAGS
-
 
3292
				if (diagnose) {
-
 
3293
					dg_whole_comp(son(e), son(son(e)));
-
 
3294
					dg_whole_comp(e, son(son(e)));
-
 
3295
				}
-
 
3296
#endif
-
 
3297
				replace(e, son(son(e)), scope);
-
 
3298
				retcell(son(e));
-
 
3299
				retcell(e);
-
 
3300
				return(1);
-
 
3301
			}
-
 
3302
			if (name(son(e)) == plus_tag && optop(e) &&
-
 
3303
			    optop(son(e))) {
-
 
3304
				/* replace negate(plus(a, b ..)) by
-
 
3305
				 * plus(negate(a), negate(b) ..)) */
-
 
3306
				exp r = getexp(sh(e), nilexp, 0, nilexp, nilexp,
-
 
3307
					       0, 0, plus_tag);
-
 
3308
				exp t = son(son(e));
-
 
3309
				exp p = r;
-
 
3310
				int lst;
-
 
3311
				do {
-
 
3312
					exp q = hold(getexp(sh(e), nilexp, 0,
-
 
3313
							    t, nilexp, 0, 0,
-
 
3314
							    neg_tag));
-
 
3315
					exp next = bro(t);
-
 
3316
					lst = (int)last(t);
-
 
3317
					bro(t) = son(q);
-
 
3318
					setlast(t);
-
 
3319
					IGNORE check(son(q), scope);
-
 
3320
					bro(p) = son(q);
-
 
3321
					retcell(q);
-
 
3322
					p = bro(p);
-
 
3323
					clearlast(p);
-
 
3324
					t = next;
-
 
3325
				} while (!lst);
-
 
3326
				son(r) = bro(r);
-
 
3327
#ifdef NEWDIAGS
-
 
3328
				if (diagnose) {
-
 
3329
					dg_whole_comp(e, r);
-
 
3330
				}
3089
#endif
3331
#endif
3090
	  replace (e, hc (r, a2), scope);
3332
				replace(e, hc(r, p), scope);
3091
	  retcell (e);
3333
				retcell(e);
3092
	  return (1);
3334
				return(1);
-
 
3335
			}
-
 
3336
			return 0;
3093
	};
3337
		}
-
 
3338
 
-
 
3339
		case shl_tag:
3094
      case neg_tag: {
3340
		case shr_tag:
-
 
3341
			if (name(bro(son(e))) == val_tag &&
3095
          if (!optop(e))
3342
			    no(bro(son(e))) == 0) {
-
 
3343
				/* remove zero place shift */
-
 
3344
				sh(son(e)) = sh(e);
-
 
3345
				replace(e, son(e), scope);
-
 
3346
				retcell(e);
3096
            return 0;
3347
				return(1);
-
 
3348
			}
3097
	  if (name (son (e)) == val_tag) {/* eval for const */
3349
			if (name(son(e)) == val_tag &&
3098
	    neg_fn (son (e));
3350
			    name(bro(son(e))) == val_tag) {
-
 
3351
				/* evaluate if both args constant */
-
 
3352
				doshl(e);
3099
	    sh(son(e)) = sh(e);
3353
				sh(son(e)) = sh(e);
-
 
3354
				replace(e, son(e), scope);
-
 
3355
				retcell(e);
-
 
3356
				return(1);
-
 
3357
			}
3100
#ifdef NEWDIAGS
3358
#if ismips
-
 
3359
			if (name(bro(son(e))) == val_tag &&
-
 
3360
			    no(bro(son(e))) == shape_size(sh(e))) {
3101
	    if (diagnose)
3361
				exp s1 = copy(e);
-
 
3362
				no(bro(son(s1)))--;
-
 
3363
				if (name(e) ==shl_tag) {
-
 
3364
					s1 = f_shift_left(f_continue, s1,
-
 
3365
					     me_shint(sh(bro(son(e))), 1));
-
 
3366
				} else {
-
 
3367
					s1 = f_shift_right(s1,
-
 
3368
					     me_shint(sh(bro(son(e))), 1));
-
 
3369
				}
-
 
3370
				replace(e, s1, scope);
-
 
3371
				kill_exp(e, scope);
-
 
3372
				return 1;
-
 
3373
			}
-
 
3374
#endif
-
 
3375
#if has_neg_shift
-
 
3376
			/* only use if the shift left and shift right
-
 
3377
			 * operations are performed by the same instruction,
-
 
3378
			 * distinguished by the sign of the number of places */
-
 
3379
			if (name(e) == shr_tag) {
3102
	      dg_whole_comp (e, son(e));
3380
				exp places = bro(son(e));
-
 
3381
				exp r;
-
 
3382
				exp neg = getexp(sh(places), nilexp, 0, places,
-
 
3383
						 nilexp, 0, 0, neg_tag);
-
 
3384
				neg = hc(neg, places);
-
 
3385
				r = getexp(sh(e), nilexp, 0, son(e), nilexp, 0,
-
 
3386
					   0, shl_tag);
-
 
3387
				bro(son(e)) = neg;
-
 
3388
				r = hc(r, neg);
-
 
3389
				replace(e, r, scope);
-
 
3390
				retcell(e);
-
 
3391
				return(1);
-
 
3392
			}
3103
#endif
3393
#endif
3648
#if has_byte_ops
3859
#if has_byte_ops
3649
	if (name(bro(son(e))) == val_tag &&
3860
			if (name(bro(son(e))) == val_tag &&
3650
	    no(bro(son(e))) == 0xff &&
3861
			    no(bro(son(e))) == 0xff &&
3651
	    name(son(e)) == shr_tag &&
3862
			    name(son(e)) == shr_tag &&
3652
	    name(son(son(e))) == cont_tag
3863
			    name(son(son(e))) == cont_tag) {
3653
	    ) {
-
 
3654
	  exp a1 = bro(son(son(e)));
3864
				exp a1 = bro(son(son(e)));
3655
	  if (name(a1) == val_tag && !isbigval(a1) &&
3865
				if (name(a1) == val_tag && !isbigval(a1) &&
3656
	      (no(a1) & 0x7) == 0) {
3866
				    (no(a1) & 0x7) == 0) {
3657
	    exp t = son(son(son(e)));
3867
					exp t = son(son(son(e)));
3658
	    exp r = me_u3(sh(t), t, reff_tag);
3868
					exp r = me_u3(sh(t), t, reff_tag);
3659
	    exp c, v;
3869
					exp c, v;
3660
#if little_end
3870
#if little_end
3661
	    no(r) = no(a1);
3871
					no(r) = no(a1);
3662
#else
3872
#else
3663
	    no(r) = shape_size(sh(e)) - no(a1) - 8;
3873
					no(r) = shape_size(sh(e)) - no(a1) - 8;
3664
#endif
-
 
3665
	    r = hold_check(r);
-
 
3666
	    c = hold_check(me_u3(ucharsh, r, cont_tag));
-
 
3667
	    v = hold_check(me_u3(sh(e), c, chvar_tag));
-
 
3668
	    replace(e, v, scope);
-
 
3669
	    retcell(e);
-
 
3670
	    return 1;
-
 
3671
	  };
-
 
3672
	};
-
 
3673
#endif
-
 
3674
	if (name(son(e)) == and_tag && name(bro(son(e))) == val_tag &&
-
 
3675
		name(bro(son(son(e)))) == val_tag
-
 
3676
		&& !isbigval(bro(son(e))) && !isbigval(bro(son(son(e))))) {
-
 
3677
	  int mask = no(bro(son(e))) & no(bro(son(son(e))));
-
 
3678
	  exp res = hold_check(me_b3(sh(e), son(son(e)),
-
 
3679
				me_shint(sh(e), mask), and_tag));
-
 
3680
	  replace(e, res, scope);
-
 
3681
	  retcell(e);
-
 
3682
	  return 1;
-
 
3683
	};
-
 
3684
	if (name(son(e)) == shr_tag && name(bro(son(e))) == val_tag &&
-
 
3685
		!isbigval(bro(son(e)))) {
-
 
3686
	  exp arg1 = son(e);
-
 
3687
	  exp arg2 = bro(arg1); /* mask */
-
 
3688
	  int m = no(arg2);
-
 
3689
	  int sz = shape_size(sh(arg1));
-
 
3690
	  if (m > 0 && name(bro(son(arg1))) == val_tag &&
-
 
3691
		!isbigval(bro(son(arg1))) &&
-
 
3692
		m <= ((1 << (sz - no(bro(son(arg1))))) - 1)) {
-
 
3693
	    exp arg11 = son(arg1);
-
 
3694
	    exp arg12 = bro(arg11); /* right shift places */
-
 
3695
	    if (name(arg11) == shl_tag &&
-
 
3696
		 name(bro(son(arg11))) == val_tag &&
-
 
3697
		!isbigval(bro(son(arg11)))) {
-
 
3698
	      exp arg111 = son(arg11);
-
 
3699
	      exp arg112 = bro(arg111); /* left shift places */
-
 
3700
	      if (no(arg112) <= no(arg12)) {
-
 
3701
		exp res = hold_check(me_b3(sh(arg1), arg111,
-
 
3702
			      me_shint(sh(arg1), no(arg12) - no(arg112)),
-
 
3703
			    shr_tag));
-
 
3704
		replace(arg1, res, res);
-
 
3705
		return check(e, scope);
-
 
3706
	      };
-
 
3707
	    };
-
 
3708
	  };
-
 
3709
	};
-
 
3710
	/* apply commutative and associative laws */
-
 
3711
	return (comm_ass (e, and_tag, and_fn, all_ones (son(e)),
-
 
3712
	      1, 0, scope, 1, 0));
-
 
3713
      case or_tag:
-
 
3714
	/* apply commutative and associative laws */
-
 
3715
	if (name(son(e)) == and_tag &&
-
 
3716
		name(bro(son(e))) == val_tag &&
-
 
3717
		!isbigval(bro(son(e))) &&
-
 
3718
		name(bro(son(son(e))))) {
-
 
3719
	  exp arg1 = son(e);
-
 
3720
	  int q = no(bro(arg1));
-
 
3721
	  exp arg11 = son(arg1);
-
 
3722
	  int p = no(bro(arg11));
-
 
3723
	  if ((q | p) == (int)0xffffffff) {
-
 
3724
	    exp res = me_b3(sh(e), arg11, bro(arg1), or_tag);
-
 
3725
	    replace(e, hold_check(res), scope);
-
 
3726
	    retcell(e);
-
 
3727
	    return 1;
-
 
3728
	  };
-
 
3729
	};
-
 
3730
	return (comm_ass (e, or_tag, or_fn, 0, shape_size(sh(e)) <= 32,
-
 
3731
		 all_ones (son(e)),
-
 
3732
	         scope, 1, 0));
-
 
3733
      case xor_tag:
-
 
3734
	/* apply commutative and associative laws */
-
 
3735
	return (comm_ass (e, xor_tag, xor_fn, 0, 0,
-
 
3736
	      0, scope, 1, 0));
-
 
3737
      case not_tag: {
-
 
3738
	  if (name (son (e)) == val_tag) {/* eval for const */
-
 
3739
	    not_fn (son (e));
-
 
3740
	    sh(son(e)) = sh(e);
-
 
3741
	    replace (e, son (e), scope);
-
 
3742
	    retcell (e);
-
 
3743
	    return (1);
-
 
3744
	  };
-
 
3745
	  if (name (son (e)) == not_tag) {/* not(not(x)) -> x */
-
 
3746
	    sh(son(son(e))) = sh(e);
-
 
3747
	    replace (e, son (son (e)), scope);
-
 
3748
	    retcell (son (e));
-
 
3749
	    retcell (e);
-
 
3750
	    return (1);
-
 
3751
	  };
-
 
3752
	  return 0;
-
 
3753
	};
-
 
3754
     case cont_tag:
-
 
3755
#ifdef promote_pars
-
 
3756
	{ int x = al1_of(sh(son(e)))->al.sh_hd;
-
 
3757
 
-
 
3758
	  if (x >= scharhd && x <= uwordhd && !little_end) {
-
 
3759
		int disp = shape_size(ulongsh)-((x>=swordhd)?16:8);
-
 
3760
		exp r = getexp(f_pointer(f_alignment(sh(e))), nilexp,
-
 
3761
					 1, son(e), nilexp, 0, disp, reff_tag);
-
 
3762
		bro(son(r)) = r;
-
 
3763
		son(e) = hold_check(r);
-
 
3764
		bro(son(e)) = e; setlast(son(e));
-
 
3765
		return 1;
-
 
3766
	  }
-
 
3767
	}
-
 
3768
#endif
-
 
3769
 
-
 
3770
#ifndef NEWDIAGS
-
 
3771
        if (name(son(e)) == diagnose_tag)
-
 
3772
          {
-
 
3773
            exp diag = son(e);
-
 
3774
            exp p = son(diag);
-
 
3775
            exp r = getexp(sh(e), nilexp, 0, p, nilexp, 0,
-
 
3776
				 0, cont_tag);
-
 
3777
            exp d;
-
 
3778
            r = hc(r, p);
-
 
3779
            d = getexp(sh(e), nilexp, 0, r, pt(diag), props(diag),
-
 
3780
                        no(diag), diagnose_tag);
-
 
3781
            setfather(d, r);
-
 
3782
            replace(e, d, scope);
-
 
3783
            retcell(son(e));
-
 
3784
            retcell(e);
-
 
3785
            return 1;
-
 
3786
          };
-
 
3787
#endif
-
 
3788
        return 0;
-
 
3789
    case field_tag:
-
 
3790
      if (name(son(e)) == compound_tag && nos (son(e))) {
-
 
3791
	exp s = son(son(e));
-
 
3792
	for(;;) {
-
 
3793
		if ( no(s)==no(e)
-
 
3794
			&& eq_shape(sh(e), sh(bro(s)))) {
-
 
3795
		   replace(e, copy(bro(s)), scope);
-
 
3796
		   kill_exp(e, scope);
-
 
3797
		   return 1;
-
 
3798
		}
-
 
3799
		if (last(bro(s))) break;
-
 
3800
		s = bro(bro(s));
-
 
3801
	}
-
 
3802
      }
-
 
3803
      if (name(son(e)) == nof_tag && nos (son(e))
-
 
3804
		&& eq_shape(sh(e), sh(son(son(e)))) ) {
-
 
3805
	exp s = son(son(e));
-
 
3806
	int sz = rounder(shape_size(sh(s)), shape_align(sh(s)));
-
 
3807
	int n = 0;
-
 
3808
	for(; no(e)<=n; n+=sz) {
-
 
3809
		if (no(e)==n) {
-
 
3810
			replace(e, copy(s), scope);
-
 
3811
			kill_exp(e, scope);
-
 
3812
		        return 1;
-
 
3813
		}
-
 
3814
		if (last(s)) break;
-
 
3815
		s = bro(s);
-
 
3816
	}
-
 
3817
      }
-
 
3818
 
-
 
3819
      if (name (son (e)) == name_tag) {
-
 
3820
	/* replace field on name by name with offset in no */
-
 
3821
	no (son (e)) += no (e);
-
 
3822
	sh (son (e)) = sh (e);
-
 
3823
	replace (e, son (e), scope);
-
 
3824
	retcell (e);
-
 
3825
	return (1);
-
 
3826
      };
-
 
3827
      if (name (son (e)) == cont_tag) {
-
 
3828
	/* replace field[n](cont(x)) by cont(reff[n](x)) */
-
 
3829
	exp arg = son (son (e));
-
 
3830
	exp rf1 = getexp (sh (arg), nilexp, 0, arg, nilexp, 0,
-
 
3831
	    no (e), reff_tag);
-
 
3832
	exp rf = hc (rf1, arg);
-
 
3833
	exp c = getexp (sh (e), nilexp, 0, rf, nilexp, 0, 0, cont_tag);
-
 
3834
	replace (e, hc (c, rf), scope);
-
 
3835
	retcell (son (e));
-
 
3836
	retcell (e);
-
 
3837
	return (1);
-
 
3838
      };
-
 
3839
      if (name(son(e)) == ident_tag && isvar(son(e)) &&
-
 
3840
           name(son(son(e))) == clear_tag &&
-
 
3841
	   name(bro(son(son(e)))) == seq_tag) {
-
 
3842
	exp var = son(e);
-
 
3843
	exp sq = bro(son(var));
-
 
3844
	if (name(bro(son(sq))) == cont_tag &&
-
 
3845
	    name(son(bro(son(sq)))) == name_tag &&
-
 
3846
	    son(son(bro(son(sq)))) == var) {
-
 
3847
	  int count = 0;
-
 
3848
	  int good = 0;
-
 
3849
	  exp p = son(son(sq));
-
 
3850
	  exp q;
-
 
3851
	  exp res;
-
 
3852
	  while (p != son(sq)) {
-
 
3853
	    if (name(p) != ass_tag || name(son(p)) != name_tag ||
-
 
3854
	        son(son(p)) != var)
-
 
3855
	      return 0;
-
 
3856
	    ++count;
-
 
3857
	    if (no(son(p)) == no(e))
-
 
3858
	      good = 1;
-
 
3859
	    p = bro(p);
-
 
3860
	  }
-
 
3861
	  if ((count+1) != no(var) || !good)
-
 
3862
	    return 0;
-
 
3863
	  p = son(son(sq));
-
 
3864
	  while (p != son(sq)) {
-
 
3865
	    q = bro(p);
-
 
3866
	    if (no(son(p)) == no(e)) {
-
 
3867
	      exp tp = f_make_top();
-
 
3868
	      res = bro(son(p));
-
 
3869
	      replace(p, tp, tp);
-
 
3870
	    }
-
 
3871
	    else {
-
 
3872
	      exp w = bro(son(p));
-
 
3873
	      replace(p, w, w);
-
 
3874
	    }
-
 
3875
	    p = q;
-
 
3876
	  }
-
 
3877
	  SET(res);
-
 
3878
	  replace(bro(son(sq)), res, res);
-
 
3879
	  replace(e, hold_check(sq), scope);
-
 
3880
	  return 1;
-
 
3881
	}
-
 
3882
	return 0;
-
 
3883
      }
-
 
3884
      return (0);
-
 
3885
    case reff_tag:
-
 
3886
      if (name (son (e)) == name_tag &&
-
 
3887
	  isvar (son (son (e))) && al1(sh(e)) > 1) {
-
 
3888
	/* replace reff on name of var by name with offset in no */
-
 
3889
	no (son (e)) += no (e);
-
 
3890
	sh (son (e)) = sh (e);
-
 
3891
#ifdef NEWDIAGS
-
 
3892
	if (diagnose)
-
 
3893
	  dg_whole_comp (e, son(e));
-
 
3894
#endif
-
 
3895
	replace (e, son (e), scope);
-
 
3896
	retcell (e);
-
 
3897
	return (1);
-
 
3898
      };
-
 
3899
 
-
 
3900
      if (name (son (e)) == val_tag) {
-
 
3901
	no (son (e)) += (no (e) / 8);
-
 
3902
	sh (son (e)) = sh (e);
-
 
3903
#ifdef NEWDIAGS
-
 
3904
	if (diagnose)
-
 
3905
	  dg_whole_comp (e, son(e));
-
 
3906
#endif
-
 
3907
	replace (e, son (e), scope);
-
 
3908
	retcell (e);
-
 
3909
	return (1);
-
 
3910
      };
-
 
3911
 
-
 
3912
#if !temp_mips
-
 
3913
      /* confirm mips doesnt need this */
-
 
3914
      if (name (son (e)) == reff_tag) {
-
 
3915
	/* combine reff selections */
-
 
3916
	sh (son (e)) = sh (e);
-
 
3917
	no (son (e)) += no (e);
-
 
3918
#ifdef NEWDIAGS
-
 
3919
	if (diagnose)
-
 
3920
	  dg_whole_comp (e, son(e));
-
 
3921
#endif
-
 
3922
	replace (e, son (e), scope);
-
 
3923
	retcell (e);
-
 
3924
	return (1);
-
 
3925
      };
-
 
3926
#endif
-
 
3927
 
-
 
3928
#if remove_zero_offsets
-
 
3929
      if (no(e) == 0 && al1(sh(e)) > 1)
-
 
3930
       {
-
 
3931
          sh(son(e)) = sh(e);
-
 
3932
#ifdef NEWDIAGS
-
 
3933
	  if (diagnose)
-
 
3934
	    dg_whole_comp (e, son(e));
-
 
3935
#endif
-
 
3936
          replace(e, son(e), scope);
-
 
3937
          retcell(e);
-
 
3938
          return 1;
-
 
3939
       };
-
 
3940
#endif
3874
#endif
3941
 
-
 
3942
        return (0);
-
 
3943
      case bfcont_tag:
-
 
3944
      case bfcontvol_tag:
-
 
3945
	{
-
 
3946
	  exp p = son(e);
3875
					r = hold_check(r);
3947
	  int bsz = shape_size(sh(e));
3876
					c = hold_check(me_u3(ucharsh, r,
3948
	  int rsz = al1(sh(p));
3877
							     cont_tag));
3949
	  int rsh;
-
 
3950
	  int sg = is_signed(sh(e));
3878
					v = hold_check(me_u3(sh(e), c,
3951
	  int off = no(e);
3879
							     chvar_tag));
3952
	  exp ref;
-
 
3953
	  exp cont;
-
 
3954
	  exp eshift;
-
 
3955
	  shape ptr_sha;
-
 
3956
	  shape msh;
-
 
3957
	  int temp = off + bsz - 1;
3880
					replace(e, v, scope);
3958
 
-
 
3959
	  if (rsz>BF_STORE_UNIT) rsz = BF_STORE_UNIT;
-
 
3960
 
-
 
3961
	  if (((off/8) == (temp/8)) &&
-
 
3962
		(bsz == 8 &&
-
 
3963
		    ((little_end && (off%8 == 0)) ||
-
 
3964
		      (!little_end && ((8 - (off % 8) - bsz) == 0))))) {
-
 
3965
	    rsz = 8;
3881
					retcell(e);
3966
	  }
-
 
3967
	  else
-
 
3968
	  if (((off/16) == (temp/16)) &&
-
 
3969
	        (bsz == 16 &&
-
 
3970
		   ((little_end && (off%16 == 0)) ||
-
 
3971
		     (!little_end && ((16 - (off % 16) - bsz) == 0))))) {
-
 
3972
	    rsz = 16;
3882
					return 1;
3973
	  }
3883
				}
3974
#if isAlpha
-
 
3975
	  else
-
 
3976
	  if (((off/32) == (temp/32)) &&
-
 
3977
	      (!sg || (al1(sh(p)) < 64) ||
-
 
3978
	        (bsz == 32 &&
-
 
3979
		   ((little_end && (off%32 == 0)) ||
-
 
3980
		     (!little_end && ((32 - (off % 32) - bsz) == 0)))))) {
-
 
3981
	    rsz = 32;
-
 
3982
	  }
3884
			}
3983
#endif
3885
#endif
-
 
3886
			if (name(son(e)) == and_tag &&
-
 
3887
			    name(bro(son(e))) == val_tag &&
-
 
3888
			    name(bro(son(son(e)))) == val_tag &&
3984
	  else {
3889
			    !isbigval(bro(son(e))) &&
3985
		/* all of bitfield must be within same integer variety */
3890
			    !isbigval(bro(son(son(e))))) {
-
 
3891
				int mask = no(bro(son(e))) &
-
 
3892
				    no(bro(son(son(e))));
3986
		while ((off/rsz) != (temp/rsz)) { rsz = rsz<<1; }
3893
				exp res = hold_check(me_b3(sh(e), son(son(e)),
-
 
3894
					  me_shint(sh(e), mask), and_tag));
-
 
3895
				replace(e, res, scope);
-
 
3896
				retcell(e);
-
 
3897
				return 1;
3987
	  }
3898
			}
-
 
3899
			if (name(son(e)) == shr_tag &&
-
 
3900
			    name(bro(son(e))) == val_tag &&
-
 
3901
			    !isbigval(bro(son(e)))) {
-
 
3902
				exp arg1 = son(e);
-
 
3903
				exp arg2 = bro(arg1); /* mask */
-
 
3904
				int m = no(arg2);
-
 
3905
				int sz = shape_size(sh(arg1));
-
 
3906
				if (m > 0 && name(bro(son(arg1))) == val_tag &&
-
 
3907
				    !isbigval(bro(son(arg1))) &&
-
 
3908
				    m <=
-
 
3909
				    ((1 << (sz - no(bro(son(arg1))))) - 1)) {
-
 
3910
					exp arg11 = son(arg1);
-
 
3911
					/* right shift places */
-
 
3912
					exp arg12 = bro(arg11);
3988
 
3913
 
-
 
3914
					if (name(arg11) == shl_tag &&
-
 
3915
					    name(bro(son(arg11))) == val_tag &&
-
 
3916
					    !isbigval(bro(son(arg11)))) {
-
 
3917
						exp arg111 = son(arg11);
-
 
3918
						/* left shift places */
-
 
3919
						exp arg112 = bro(arg111);
-
 
3920
 
-
 
3921
						if (no(arg112) <= no(arg12)) {
-
 
3922
						  exp res =
-
 
3923
						      hold_check(me_b3(sh(arg1),
-
 
3924
						      arg111, me_shint(sh(arg1),
-
 
3925
						      no(arg12) - no(arg112)),
-
 
3926
						      shr_tag));
-
 
3927
							replace(arg1, res, res);
-
 
3928
							return check(e, scope);
-
 
3929
						}
-
 
3930
					}
-
 
3931
				}
-
 
3932
			}
-
 
3933
			/* apply commutative and associative laws */
-
 
3934
			return(comm_ass(e, and_tag, and_fn, all_ones(son(e)), 1,
-
 
3935
					0, scope, 1, 0));
-
 
3936
		case or_tag:
-
 
3937
			/* apply commutative and associative laws */
-
 
3938
			if (name(son(e)) == and_tag &&
-
 
3939
			    name(bro(son(e))) == val_tag &&
-
 
3940
			    !isbigval(bro(son(e))) &&
-
 
3941
			    name(bro(son(son(e))))) {
-
 
3942
				exp arg1 = son(e);
-
 
3943
				int q = no(bro(arg1));
-
 
3944
				exp arg11 = son(arg1);
-
 
3945
				int p = no(bro(arg11));
-
 
3946
				if ((q | p) == (int)0xffffffff) {
-
 
3947
					exp res = me_b3(sh(e), arg11, bro(arg1),
-
 
3948
							or_tag);
-
 
3949
					replace(e, hold_check(res), scope);
-
 
3950
					retcell(e);
-
 
3951
					return 1;
-
 
3952
				}
-
 
3953
			}
-
 
3954
			return(comm_ass(e, or_tag, or_fn, 0,
-
 
3955
					shape_size(sh(e)) <= 32,
-
 
3956
					all_ones(son(e)), scope, 1, 0));
-
 
3957
		case xor_tag:
-
 
3958
			/* apply commutative and associative laws */
-
 
3959
			return(comm_ass(e, xor_tag, xor_fn, 0, 0, 0, scope, 1,
-
 
3960
					0));
-
 
3961
		case not_tag:
-
 
3962
			if (name(son(e)) == val_tag) {
-
 
3963
				/* eval for const */
-
 
3964
				not_fn(son(e));
-
 
3965
				sh(son(e)) = sh(e);
-
 
3966
				replace(e, son(e), scope);
-
 
3967
				retcell(e);
-
 
3968
				return(1);
-
 
3969
			}
-
 
3970
			if (name(son(e)) == not_tag) {
-
 
3971
				/* not(not(x))->x */
-
 
3972
				sh(son(son(e))) = sh(e);
-
 
3973
				replace(e, son(son(e)), scope);
-
 
3974
				retcell(son(e));
-
 
3975
				retcell(e);
-
 
3976
				return(1);
-
 
3977
			}
-
 
3978
			return 0;
3989
 
3979
 
-
 
3980
		case cont_tag:
-
 
3981
#ifdef promote_pars
-
 
3982
		{
-
 
3983
			int x = al1_of(sh(son(e)))->al.sh_hd;
-
 
3984
 
-
 
3985
			if (x >= scharhd && x <= uwordhd && !little_end) {
3990
	  msh = containedshape(rsz, sg);
3986
				int disp = shape_size(ulongsh) -
-
 
3987
				    ((x >= swordhd) ? 16 : 8);
3991
	  ptr_sha = f_pointer(long_to_al(rsz));
3988
				exp r = getexp(f_pointer(f_alignment(sh(e))),
3992
	  if ((off / rsz) != 0) {
3989
					       nilexp, 1, son(e), nilexp, 0,
3993
	    ref = me_u3(ptr_sha, p, reff_tag);
3990
					       disp, reff_tag);
3994
	    no(ref) = (off / rsz) * rsz;
3991
				bro(son(r)) = r;
3995
	    ref = hold_check(ref);
3992
				son(e) = hold_check(r);
-
 
3993
				bro(son(e)) = e;
-
 
3994
				setlast(son(e));
-
 
3995
				return 1;
3996
	  }
3996
			}
-
 
3997
		}
-
 
3998
#endif
-
 
3999
 
-
 
4000
#ifndef NEWDIAGS
-
 
4001
			if (name(son(e)) == diagnose_tag) {
-
 
4002
				exp diag = son(e);
-
 
4003
				exp p = son(diag);
-
 
4004
				exp r = getexp(sh(e), nilexp, 0, p, nilexp, 0,
-
 
4005
					       0, cont_tag);
3997
	  else
4006
				exp d;
3998
	    ref = p;
4007
				r = hc(r, p);
-
 
4008
				d = getexp(sh(e), nilexp, 0, r, pt(diag),
-
 
4009
					   props(diag), no(diag), diagnose_tag);
-
 
4010
				setfather(d, r);
-
 
4011
				replace(e, d, scope);
-
 
4012
				retcell(son(e));
3999
#if little_end
4013
				retcell(e);
-
 
4014
				return 1;
-
 
4015
			}
-
 
4016
#endif
-
 
4017
			return 0;
-
 
4018
 
-
 
4019
		case field_tag:
-
 
4020
			if (name(son(e)) == compound_tag && nos(son(e))) {
-
 
4021
				exp s = son(son(e));
-
 
4022
				for (;;) {
-
 
4023
					if (no(s) ==no(e) &&
-
 
4024
					    eq_shape(sh(e), sh(bro(s)))) {
-
 
4025
						replace(e, copy(bro(s)), scope);
-
 
4026
						kill_exp(e, scope);
-
 
4027
						return 1;
-
 
4028
					}
-
 
4029
					if (last(bro(s))) {
-
 
4030
						break;
-
 
4031
					}
4000
	  rsh = off % rsz;
4032
					s = bro(bro(s));
4001
#else
4033
				}
-
 
4034
			}
-
 
4035
			if (name(son(e)) == nof_tag && nos(son(e))
-
 
4036
			    && eq_shape(sh(e), sh(son(son(e))))) {
-
 
4037
				exp s = son(son(e));
-
 
4038
				int sz = rounder(shape_size(sh(s)),
-
 
4039
						 shape_align(sh(s)));
-
 
4040
				int n = 0;
4002
	  rsh = rsz - (off % rsz) - bsz;
4041
				for (; no(e) <= n; n += sz) {
-
 
4042
					if (no(e) ==n) {
-
 
4043
						replace(e, copy(s), scope);
-
 
4044
						kill_exp(e, scope);
-
 
4045
						return 1;
-
 
4046
					}
-
 
4047
					if (last(s)) {
-
 
4048
						break;
4003
#endif
4049
					}
-
 
4050
					s = bro(s);
-
 
4051
				}
-
 
4052
			}
-
 
4053
 
-
 
4054
			if (name(son(e)) == name_tag) {
-
 
4055
				/* replace field on name by name with offset in
-
 
4056
				 * no */
-
 
4057
				no(son(e)) += no(e);
4004
	  cont = me_u3(msh, ref,
4058
				sh(son(e)) = sh(e);
-
 
4059
				replace(e, son(e), scope);
-
 
4060
				retcell(e);
-
 
4061
				return(1);
-
 
4062
			}
4005
			(name(e) == bfcont_tag)
4063
			if (name(son(e)) == cont_tag) {
-
 
4064
				/* replace field[n](cont(x)) by
-
 
4065
				 * cont(reff[n](x)) */
-
 
4066
				exp arg = son(son(e));
-
 
4067
				exp rf1 = getexp(sh(arg), nilexp, 0, arg,
-
 
4068
						 nilexp, 0, no(e), reff_tag);
-
 
4069
				exp rf = hc(rf1, arg);
-
 
4070
				exp c = getexp(sh(e), nilexp, 0, rf, nilexp, 0,
4006
			  ? (unsigned char)cont_tag
4071
					       0, cont_tag);
-
 
4072
				replace(e, hc(c, rf), scope);
-
 
4073
				retcell(son(e));
-
 
4074
				retcell(e);
-
 
4075
				return(1);
-
 
4076
			}
-
 
4077
			if (name(son(e)) == ident_tag && isvar(son(e)) &&
4007
			  : (unsigned char)contvol_tag);
4078
			    name(son(son(e))) == clear_tag &&
4008
	  if (rsh==0 && !sg && bsz != rsz) {
4079
			    name(bro(son(son(e)))) == seq_tag) {
-
 
4080
				exp var = son(e);
4009
	      eshift = me_b3(msh, cont,
4081
				exp sq = bro(son(var));
-
 
4082
				if (name(bro(son(sq))) == cont_tag &&
-
 
4083
				    name(son(bro(son(sq)))) == name_tag &&
4010
				 me_shint(slongsh, (1<<bsz)-1), and_tag);
4084
				    son(son(bro(son(sq)))) == var) {
-
 
4085
					int count = 0;
-
 
4086
					int good = 0;
-
 
4087
					exp p = son(son(sq));
4011
          }
4088
					exp q;
-
 
4089
					exp res;
-
 
4090
					while (p != son(sq)) {
-
 
4091
						if (name(p) != ass_tag ||
-
 
4092
						    name(son(p)) != name_tag ||
-
 
4093
						    son(son(p)) != var) {
-
 
4094
							return 0;
-
 
4095
						}
-
 
4096
						++count;
-
 
4097
						if (no(son(p)) == no(e)) {
-
 
4098
							good = 1;
-
 
4099
						}
-
 
4100
						p = bro(p);
-
 
4101
					}
-
 
4102
					if ((count + 1) != no(var) || !good) {
-
 
4103
						return 0;
-
 
4104
					}
-
 
4105
					p = son(son(sq));
-
 
4106
					while (p != son(sq)) {
-
 
4107
						q = bro(p);
-
 
4108
						if (no(son(p)) == no(e)) {
-
 
4109
							exp tp = f_make_top();
-
 
4110
							res = bro(son(p));
-
 
4111
							replace(p, tp, tp);
4012
	  else {
4112
						} else {
-
 
4113
							exp w = bro(son(p));
-
 
4114
							replace(p, w, w);
-
 
4115
						}
-
 
4116
						p = q;
-
 
4117
					}
-
 
4118
					SET(res);
4013
	    if (rsz - bsz - rsh != 0) {
4119
					replace(bro(son(sq)), res, res);
4014
		cont = me_b3(msh, cont, me_shint(slongsh,rsz - bsz - rsh),
4120
					replace(e, hold_check(sq), scope);
4015
					shl_tag);
4121
					return 1;
4016
	    }
4122
				}
-
 
4123
				return 0;
-
 
4124
			}
-
 
4125
			return(0);
4017
 
4126
 
-
 
4127
		case reff_tag:
4018
	    if (rsz - bsz != 0)
4128
			if (name(son(e)) == name_tag &&
4019
	       eshift = me_b3(msh, cont, me_shint(slongsh, rsz-bsz),
4129
			    isvar(son(son(e))) && al1(sh(e)) > 1) {
-
 
4130
				/* replace reff on name of var by name with
-
 
4131
				 * offset in no */
-
 
4132
				no(son(e)) += no(e);
4020
				shr_tag);
4133
				sh(son(e)) = sh(e);
-
 
4134
#ifdef NEWDIAGS
4021
	    else
4135
				if (diagnose) {
4022
	    eshift = cont;
4136
					dg_whole_comp(e, son(e));
4023
	  }
4137
				}
-
 
4138
#endif
4024
	  eshift = me_u3(sh(e), eshift, chvar_tag);
4139
				replace(e, son(e), scope);
-
 
4140
				retcell(e);
-
 
4141
				return(1);
-
 
4142
			}
4025
 
4143
 
-
 
4144
			if (name(son(e)) == val_tag) {
-
 
4145
				no(son(e)) += (no(e) / 8);
-
 
4146
				sh(son(e)) = sh(e);
-
 
4147
#ifdef NEWDIAGS
-
 
4148
				if (diagnose) {
-
 
4149
					dg_whole_comp(e, son(e));
-
 
4150
				}
-
 
4151
#endif
4026
	  replace(e, eshift , scope);
4152
				replace(e, son(e), scope);
4027
	  retcell(e);
4153
				retcell(e);
4028
	  return 1;
4154
				return(1);
4029
	};
4155
			}
-
 
4156
 
4030
      case abs_tag:
4157
#if !temp_mips
-
 
4158
			/* confirm mips doesnt need this */
4031
	if (name (son (e)) == val_tag) {
4159
			if (name(son(e)) == reff_tag) {
-
 
4160
				/* combine reff selections */
4032
	  if (is_signed(sh(e)) &&
4161
				sh(son(e)) = sh(e);
4033
	  	((isbigval(son(e)) && flptnos[no(son(e))].sign) ||
4162
				no(son(e)) += no(e);
-
 
4163
#ifdef NEWDIAGS
-
 
4164
				if (diagnose) {
4034
		 (!isbigval(son(e)) && no(son(e)) < 0))) {/* eval for const */
4165
					dg_whole_comp(e, son(e));
-
 
4166
				}
-
 
4167
#endif
4035
	    if (!optop(e)) return 0;
4168
				replace(e, son(e), scope);
4036
	    neg_fn (son (e));
4169
				retcell(e);
-
 
4170
				return(1);
4037
	  }
4171
			}
-
 
4172
#endif
-
 
4173
 
-
 
4174
#if remove_zero_offsets
-
 
4175
			if (no(e) == 0 && al1(sh(e)) > 1) {
4038
	  sh(son(e)) = sh(e);
4176
				sh(son(e)) = sh(e);
4039
#ifdef NEWDIAGS
4177
#ifdef NEWDIAGS
4040
	  if (diagnose)
4178
				if (diagnose) {
4041
	    dg_whole_comp (e, son(e));
4179
					dg_whole_comp(e, son(e));
-
 
4180
				}
-
 
4181
#endif
-
 
4182
				replace(e, son(e), scope);
-
 
4183
				retcell(e);
-
 
4184
				return 1;
-
 
4185
			}
4042
#endif
4186
#endif
4043
	  replace (e, son (e), scope);
-
 
4044
	  retcell (e);
-
 
4045
	  return (1);
-
 
4046
	};
-
 
4047
	return 0;
-
 
4048
      case fmax_tag:
-
 
4049
       case fmin_tag:
-
 
4050
	{
-
 
4051
	  bool fmin = (name(e)==fmin_tag);
-
 
4052
	  exp arg1 = son(e);
-
 
4053
	  exp arg2 = bro(arg1);
-
 
4054
	  exp id1 = me_startid(sh(arg1),arg1,0);/* identify arg1 */
-
 
4055
	  exp id2 = me_startid(sh(arg2),arg2,0);/* identify arg2 */
-
 
4056
	  exp seq;
-
 
4057
	  exp cond;
-
 
4058
	  exp zero;
-
 
4059
	  exp lab;
-
 
4060
	  exp clear;
-
 
4061
	  exp test;
-
 
4062
 
-
 
4063
	  clear = getexp(f_bottom,nilexp,0,nilexp,nilexp,0,0,clear_tag);
-
 
4064
	  lab = me_b3(sh(arg2),clear,me_obtain(id2),labst_tag);
-
 
4065
	  test = me_q2(no_nat_option,
-
 
4066
		       f_impossible,
-
 
4067
		       fmin?f_less_than:f_greater_than,
-
 
4068
		       &lab,
-
 
4069
		       me_obtain(id1),
-
 
4070
		       me_obtain(id2),
-
 
4071
		       test_tag);
-
 
4072
	  zero = me_u3(sh(test),test,0);
-
 
4073
	  seq = me_b3(sh(arg1),zero,me_obtain(id1),seq_tag);
-
 
4074
	  cond = me_b3(sh(arg1),seq,lab,cond_tag);
-
 
4075
	  id2 = me_complete_id(id2,cond);
-
 
4076
	  id1 = me_complete_id(id1,id2);
-
 
4077
	  replace(e,id1,scope);
-
 
4078
	  retcell(e);
-
 
4079
	  return 1;
-
 
4080
	}
-
 
4081
      case name_tag: {
-
 
4082
	  exp s = son(e);
-
 
4083
	  if (!isvar(s) && isglob(s) && son(s) != nilexp
-
 
4084
		&& name(sh(e)) == name(sh(son(s)))
-
 
4085
		&& (name(son(s)) == val_tag || name(son(s))==real_tag)) {
-
 
4086
		exp c = copy(son(s));
-
 
4087
		replace(e,c,scope);
-
 
4088
		kill_exp(e,scope);
-
 
4089
		return 1;
-
 
4090
	   }
-
 
4091
	   else return 0;
-
 
4092
 
4187
 
4093
      }
-
 
4094
      case fpower_tag:
-
 
4095
      case imag_tag:
-
 
4096
      case make_complex_tag:
-
 
4097
	return 0;
4188
			return(0);
4098
      case rotl_tag:
4189
		case bfcont_tag:
4099
      case rotr_tag:
4190
		case bfcontvol_tag: {
4100
      case env_offset_tag:
-
 
4101
      case general_env_offset_tag:
-
 
4102
      case proc_tag:
4191
			exp p = son(e);
4103
      case general_proc_tag:
4192
			int bsz = shape_size(sh(e));
4104
      case top_tag:
-
 
4105
      case val_tag:
4193
			int rsz = al1(sh(p));
4106
      case real_tag:
4194
			int rsh;
4107
      case current_env_tag:
4195
			int sg = is_signed(sh(e));
4108
      case make_lv_tag:
4196
			int off = no(e);
4109
      case clear_tag:
4197
			exp ref;
4110
      case null_tag:
4198
			exp cont;
4111
      case string_tag:
4199
			exp eshift;
4112
      case power_tag:
4200
			shape ptr_sha;
4113
      case contvol_tag:
-
 
4114
        return 0;
-
 
4115
      default:
4201
			shape msh;
4116
        return 0;
4202
			int temp = off + bsz - 1;
4117
    };
-
 
4118
  };
4203
 
-
 
4204
			if (rsz>BF_STORE_UNIT)rsz = BF_STORE_UNIT;
4119
 
4205
 
4120
 
-
 
4121
  switch (name (e)) {		/* side effecting ops */
4206
			if (((off / 8) == (temp / 8)) &&
4122
    case compound_tag:
4207
			    (bsz == 8 &&
-
 
4208
			     ((little_end && (off % 8 == 0)) ||
-
 
4209
			      (!little_end && ((8 - (off % 8) - bsz) == 0))))) {
4123
      {
4210
				rsz = 8;
-
 
4211
			} else if (((off / 16) == (temp / 16)) &&
4124
       exp bse = bro(son(e));
4212
				    (bsz == 16 &&
4125
       unsigned char shn = name(sh(bse));
4213
				     ((little_end && (off % 16 == 0)) ||
-
 
4214
				      (!little_end &&
4126
       if (last(bse) && name(son(e)) == val_tag &&
4215
				       ((16 - (off % 16) - bsz) == 0))))) {
-
 
4216
				rsz = 16;
-
 
4217
			}
-
 
4218
#if isAlpha
4127
             no(son(e)) == 0 &&
4219
			else if (((off / 32) == (temp / 32)) &&
4128
              shape_size(sh(e)) == shape_size(sh(bse)) &&
4220
				 (!sg || (al1(sh(p)) < 64) ||
-
 
4221
				  (bsz == 32 &&
4129
              shn != prokhd && (shn < shrealhd || shn > doublehd)
4222
				   ((little_end && (off % 32 == 0)) ||
4130
#if dont_unpad_apply
4223
				    (!little_end &&
4131
                 && name(bse) != apply_tag
4224
				     ((32 - (off % 32) - bsz) == 0)))))) {
-
 
4225
				rsz = 32;
-
 
4226
			}
4132
#endif
4227
#endif
-
 
4228
			else {
-
 
4229
				/* all of bitfield must be within same integer
-
 
4230
				 * variety */
-
 
4231
				while ((off / rsz) != (temp / rsz)) {
-
 
4232
					rsz = rsz << 1;
-
 
4233
				}
-
 
4234
			}
-
 
4235
 
-
 
4236
			msh = containedshape(rsz, sg);
-
 
4237
			ptr_sha = f_pointer(long_to_al(rsz));
-
 
4238
			if ((off / rsz) != 0) {
-
 
4239
				ref = me_u3(ptr_sha, p, reff_tag);
-
 
4240
				no(ref) = (off / rsz) * rsz;
-
 
4241
				ref = hold_check(ref);
-
 
4242
			} else {
-
 
4243
				ref = p;
-
 
4244
			}
-
 
4245
#if little_end
-
 
4246
			rsh = off % rsz;
-
 
4247
#else
-
 
4248
			rsh = rsz - (off % rsz) - bsz;
-
 
4249
#endif
-
 
4250
			cont = me_u3(msh, ref, (name(e) == bfcont_tag) ? 
-
 
4251
				     (unsigned char)cont_tag :
-
 
4252
				     (unsigned char)contvol_tag);
-
 
4253
			if (rsh == 0 && !sg && bsz != rsz) {
-
 
4254
				eshift = me_b3(msh, cont,
-
 
4255
					       me_shint(slongsh, (1 << bsz) -1),
-
 
4256
					       and_tag);
-
 
4257
			} else {
-
 
4258
				if (rsz - bsz - rsh != 0) {
-
 
4259
					cont = me_b3(msh, cont,
-
 
4260
						     me_shint(slongsh, rsz -
-
 
4261
						     bsz - rsh), shl_tag);
-
 
4262
				}
-
 
4263
 
-
 
4264
				if (rsz - bsz != 0) {
-
 
4265
					eshift = me_b3(msh, cont,
-
 
4266
						       me_shint(slongsh, rsz -
-
 
4267
								bsz), shr_tag);
-
 
4268
				} else {
-
 
4269
					eshift = cont;
-
 
4270
				}
-
 
4271
			}
-
 
4272
			eshift = me_u3(sh(e), eshift, chvar_tag);
-
 
4273
 
-
 
4274
			replace(e, eshift , scope);
-
 
4275
			retcell(e);
-
 
4276
			return 1;
-
 
4277
		}
-
 
4278
 
-
 
4279
		case abs_tag:
-
 
4280
			if (name(son(e)) == val_tag) {
-
 
4281
				if (is_signed(sh(e)) &&
-
 
4282
				    ((isbigval(son(e)) &&
-
 
4283
				      flptnos[no(son(e))].sign) ||
-
 
4284
				     (!isbigval(son(e)) &&
-
 
4285
				      no(son(e)) < 0))) {
-
 
4286
					/* eval for const */
-
 
4287
					if (!optop(e)) {
-
 
4288
						return 0;
-
 
4289
					}
-
 
4290
					neg_fn(son(e));
-
 
4291
				}
-
 
4292
				sh(son(e)) = sh(e);
-
 
4293
#ifdef NEWDIAGS
-
 
4294
				if (diagnose) {
-
 
4295
					dg_whole_comp(e, son(e));
-
 
4296
				}
-
 
4297
#endif
-
 
4298
				replace(e, son(e), scope);
-
 
4299
				retcell(e);
-
 
4300
				return(1);
-
 
4301
			}
-
 
4302
			return 0;
-
 
4303
 
-
 
4304
		case fmax_tag:
-
 
4305
		case fmin_tag: {
-
 
4306
			bool fmin = (name(e) ==fmin_tag);
-
 
4307
			exp arg1 = son(e);
-
 
4308
			exp arg2 = bro(arg1);
-
 
4309
			/* identify arg1 */
-
 
4310
			exp id1 = me_startid(sh(arg1), arg1, 0);
-
 
4311
			/* identify arg2 */
-
 
4312
			exp id2 = me_startid(sh(arg2), arg2, 0);
-
 
4313
 
-
 
4314
			exp seq;
-
 
4315
			exp cond;
-
 
4316
			exp zero;
-
 
4317
			exp lab;
-
 
4318
			exp clear;
-
 
4319
			exp test;
-
 
4320
 
-
 
4321
			clear = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
-
 
4322
				       0, clear_tag);
-
 
4323
			lab = me_b3(sh(arg2), clear, me_obtain(id2), labst_tag);
-
 
4324
			test = me_q2(no_nat_option, f_impossible,
-
 
4325
				     fmin ? f_less_than : f_greater_than,
-
 
4326
				     &lab, me_obtain(id1), me_obtain(id2),
-
 
4327
				     test_tag);
-
 
4328
			zero = me_u3(sh(test), test, 0);
-
 
4329
			seq = me_b3(sh(arg1), zero, me_obtain(id1), seq_tag);
-
 
4330
			cond = me_b3(sh(arg1), seq, lab, cond_tag);
-
 
4331
			id2 = me_complete_id(id2, cond);
-
 
4332
			id1 = me_complete_id(id1, id2);
-
 
4333
			replace(e, id1, scope);
-
 
4334
			retcell(e);
-
 
4335
			return 1;
-
 
4336
		}
-
 
4337
 
-
 
4338
		case name_tag: {
-
 
4339
			exp s = son(e);
-
 
4340
			if (!isvar(s) && isglob(s) && son(s) != nilexp &&
-
 
4341
			    name(sh(e)) == name(sh(son(s))) &&
-
 
4342
			    (name(son(s)) == val_tag ||
-
 
4343
			     name(son(s)) == real_tag)) {
-
 
4344
				exp c = copy(son(s));
-
 
4345
				replace(e, c, scope);
-
 
4346
				kill_exp(e, scope);
-
 
4347
				return 1;
-
 
4348
			} else {
-
 
4349
				return 0;
-
 
4350
			}
-
 
4351
 
-
 
4352
		}
-
 
4353
		case fpower_tag:
-
 
4354
		case imag_tag:
-
 
4355
		case make_complex_tag:
-
 
4356
			return 0;
-
 
4357
		case rotl_tag:
-
 
4358
		case rotr_tag:
-
 
4359
		case env_offset_tag:
-
 
4360
		case general_env_offset_tag:
-
 
4361
		case proc_tag:
-
 
4362
		case general_proc_tag:
-
 
4363
		case top_tag:
-
 
4364
		case val_tag:
-
 
4365
		case real_tag:
-
 
4366
		case current_env_tag:
-
 
4367
		case make_lv_tag:
-
 
4368
		case clear_tag:
-
 
4369
		case null_tag:
-
 
4370
		case string_tag:
-
 
4371
		case power_tag:
-
 
4372
		case contvol_tag:
-
 
4373
			return 0;
-
 
4374
		default:
-
 
4375
			return 0;
-
 
4376
		}
-
 
4377
	}
-
 
4378
 
-
 
4379
	/* side effecting ops */
-
 
4380
	switch (name(e)) {
-
 
4381
	case compound_tag: {
-
 
4382
		exp bse = bro(son(e));
-
 
4383
		unsigned char shn = name(sh(bse));
-
 
4384
		if (last(bse) && name(son(e)) == val_tag &&
-
 
4385
		    no(son(e)) == 0 &&
-
 
4386
		    shape_size(sh(e)) == shape_size(sh(bse)) &&
-
 
4387
		    shn != prokhd && (shn < shrealhd || shn > doublehd)
-
 
4388
#if dont_unpad_apply
-
 
4389
		    && name(bse) != apply_tag
-
 
4390
#endif
4133
          )
4391
		   ) {
4134
        {  /* remove the creation of a compound if it consists of a
4392
			/* remove the creation of a compound if it consists of
4135
              single value of the same size and provided that the
4393
			 * a single value of the same size and provided that
4136
              component is not real (because it might be in the wrong
4394
			 * the component is not real (because it might be in
4137
              place. */
4395
			 * the wrong place. */
4138
          if (name(bse) == name_tag && isvar(son(bse)) &&
4396
			if (name(bse) == name_tag && isvar(son(bse)) &&
4139
                !isglob(son(bse)) &&
4397
			    !isglob(son(bse)) &&
4140
                name(sh(son(son(bse)))) >= shrealhd &&
4398
			    name(sh(son(son(bse)))) >= shrealhd &&
4141
                name(sh(son(son(bse)))) <= doublehd)  {
4399
			    name(sh(son(son(bse)))) <= doublehd) {
4142
            setvis(son(bse));
4400
				setvis(son(bse));
4143
            props(e) = (prop)(props(e) & ~0x08);
4401
				props(e) = (prop)(props(e) & ~0x08);
4144
          };
4402
			}
4145
          sh(bse) = sh(e);
4403
			sh(bse) = sh(e);
4146
#ifdef NEWDIAGS
4404
#ifdef NEWDIAGS
4147
	  if (diagnose)
4405
			if (diagnose) {
4148
	    dg_whole_comp (e, bse);
4406
				dg_whole_comp(e, bse);
-
 
4407
			}
4149
#endif
4408
#endif
4150
          replace(e, bse, scope);
4409
			replace(e, bse, scope);
4151
          retcell(son(e));
4410
			retcell(son(e));
4152
          retcell(e);
4411
			retcell(e);
4153
          return 1;
4412
			return 1;
4154
        };
4413
		}
4155
       };
4414
	}
4156
#if replace_compound
4415
#if replace_compound
4157
      if (in_proc_def)
4416
		if (in_proc_def) {
4158
      {  /* Provided that the exp is inside a procedure definition we
4417
			/* Provided that the exp is inside a procedure
4159
            always remove compound creation and replace it by a
4418
			 * definition we always remove compound creation and
4160
            variable declaration for the compound, assignments to
4419
			 * replace it by a variable declaration for the
4161
            the components, and deliver the compound. */
4420
			 * compound, assignments to the components, and deliver
-
 
4421
			 * the compound. */
4162
        shape she = sh(e);
4422
			shape she = sh(e);
4163
        exp var = me_start_clearvar(she, she);
4423
			exp var = me_start_clearvar(she, she);
4164
        exp cont = getexp(she, nilexp, 0, nilexp, nilexp, 0, 0, cont_tag);
4424
			exp cont = getexp(she, nilexp, 0, nilexp, nilexp, 0, 0,
-
 
4425
					  cont_tag);
4165
        exp_list el;
4426
			exp_list el;
4166
        exp obt;
4427
			exp obt;
4167
        exp t = son(e);
4428
			exp t = son(e);
4168
        exp seq;
4429
			exp seq;
4169
        obt = me_obtain(var);
4430
			obt = me_obtain(var);
4170
        son(cont) = obt;
4431
			son(cont) = obt;
4171
        setfather(cont, obt);
4432
			setfather(cont, obt);
4172
        el = new_exp_list(0);
4433
			el = new_exp_list(0);
4173
 
4434
 
4174
        while (1)
4435
			while (1) {
4175
         {
-
 
4176
           exp q = bro(t);  /* expression being assigned */
4436
				exp q = bro(t);	/* expression being assigned */
4177
           exp n = bro(q);
4437
				exp n = bro(q);
4178
           int end = (int)last(q);
4438
				int end = (int)last(q);
4179
           exp ass, p, ap;
4439
				exp ass, p, ap;
4180
           p = me_obtain(var);
4440
				p = me_obtain(var);
4181
	   if (name(sh(q)) != bitfhd || !newcode) {
4441
				if (name(sh(q)) != bitfhd || !newcode) {
-
 
4442
					/* destination */
4182
             ap = hold_check(f_add_to_ptr(p, t));  /* destination */
4443
					ap = hold_check(f_add_to_ptr(p, t));
4183
             ass = hold_check(f_assign(ap, q));
4444
					ass = hold_check(f_assign(ap, q));
4184
	   }
-
 
4185
	   else {
4445
				} else {
4186
	     ass = hold_check(f_bitfield_assign(p, t, q));
4446
					ass = hold_check(f_bitfield_assign(p, t,
-
 
4447
									   q));
4187
	   };
4448
				}
4188
           el = add_exp_list(el, ass, 0);
4449
				el = add_exp_list(el, ass, 0);
4189
           if (end)
4450
				if (end) {
4190
             break;
4451
					break;
-
 
4452
				}
4191
           t = n;
4453
				t = n;
4192
         };
4454
			}
4193
        seq = f_sequence(el, cont);
4455
			seq = f_sequence(el, cont);
4194
#ifdef NEWDIAGS
4456
#ifdef NEWDIAGS
4195
	if (diagnose)
4457
			if (diagnose) {
4196
	  dg_whole_comp (e, var);
4458
				dg_whole_comp(e, var);
-
 
4459
			}
4197
#endif
4460
#endif
4198
        replace(e, me_complete_id(var, seq), scope);
4461
			replace(e, me_complete_id(var, seq), scope);
4199
        retcell(e);
4462
			retcell(e);
4200
        return 1;
4463
			return 1;
4201
      };
4464
		}
4202
#endif
4465
#endif
4203
      return 0;
4466
		return 0;
4204
#ifndef NEWDIAGS
4467
#ifndef NEWDIAGS
4205
    case diagnose_tag:
4468
	case diagnose_tag:
4206
#endif
4469
#endif
4207
    case prof_tag:
4470
	case prof_tag:
4208
      return 0;
4471
		return 0;
4209
    case ident_tag:
4472
	case ident_tag:
4210
      if (name(sh(son(e))) == bothd)
4473
		if (name(sh(son(e))) == bothd) {
4211
        {
-
 
4212
         exp s = son(e);
4474
			exp s = son(e);
4213
         exp b = bro(s);
4475
			exp b = bro(s);
4214
#ifdef NEWDIAGS
4476
#ifdef NEWDIAGS
4215
	 if (diagnose) {
4477
			if (diagnose) {
4216
	   dg_dead_code (b, s);
4478
				dg_dead_code(b, s);
4217
	   dg_whole_comp (e, s);
4479
				dg_whole_comp(e, s);
4218
	 }
4480
			}
4219
#endif
4481
#endif
4220
         kill_exp(b, b);
4482
			kill_exp(b, b);
4221
         replace(e, s, scope);
4483
			replace(e, s, scope);
4222
         retcell(e);
4484
			retcell(e);
4223
         return 1;
4485
			return 1;
4224
        };
4486
		}
4225
#if has_setcc
4487
#if has_setcc
4226
      /* use if target has setcc instruction */
4488
		/* use if target has setcc instruction */
4227
      if (!is80x86 || is80586) {
4489
		if (!is80x86 || is80586) {
4228
	exp abst = absbool (e);
4490
			exp abst = absbool(e);
4229
	if (abst != nilexp &&
4491
			if (abst != nilexp &&
4230
		(!is80x86 || name(sh(son(abst))) <= u64hd)) {
4492
			    (!is80x86 || name(sh(son(abst))) <= u64hd)) {
4231
	  /* check if we can use setcc */
4493
				/* check if we can use setcc */
4232
	  exp a = copy (abst);
4494
				exp a = copy(abst);
4233
	  setname (a, absbool_tag);
4495
				setname(a, absbool_tag);
4234
	  pt (a) = nilexp;
4496
				pt(a) = nilexp;
4235
	  sh (a) = sh (e);
4497
				sh(a) = sh(e);
4236
#ifdef NEWDIAGS
4498
#ifdef NEWDIAGS
4237
	  if (diagnose)
4499
				if (diagnose) {
4238
	    dg_whole_comp (e, a);
4500
					dg_whole_comp(e, a);
-
 
4501
				}
4239
#endif
4502
#endif
4240
	  replace (e, a, a);
4503
				replace(e, a, a);
4241
	  kill_exp (e, e);
4504
				kill_exp(e, e);
4242
	  return (0);
4505
				return(0);
4243
	};
4506
			}
4244
      };
4507
		}
4245
#endif
4508
#endif
4246
      if (name(sh(bro(son(e)))) != name(sh(e))) {
4509
		if (name(sh(bro(son(e)))) != name(sh(e))) {
4247
		sh(e) = sh(bro(son(e)));
4510
			sh(e) = sh(bro(son(e)));
4248
		IGNORE check_id(e,scope);
4511
			IGNORE check_id(e, scope);
4249
		return 1;
4512
			return 1;
4250
      }
4513
		}
4251
      return (check_id (e, scope));/* see check_id.c */
4514
		return (check_id (e, scope));	/* see check_id.c */
-
 
4515
 
4252
    case seq_tag:
4516
	case seq_tag:
4253
      if (son (son (e)) == nilexp) {/* remove empty seq */
4517
		if (son(son(e)) == nilexp) {
-
 
4518
			/* remove empty seq */
4254
        exp s = son(e);
4519
			exp s = son(e);
4255
	sh(bro(s)) = sh(e);	/* unless bottom ???????????????????????????? */
4520
			sh(bro(s)) = sh(e);	/* unless bottom ? */
4256
 
4521
 
4257
#ifdef NEWDIAGS
4522
#ifdef NEWDIAGS
4258
	if (diagnose)
4523
			if (diagnose) {
4259
	  dg_whole_comp (e, bro(s));
4524
				dg_whole_comp(e, bro(s));
-
 
4525
			}
4260
#endif
4526
#endif
4261
	replace (e, bro (s), scope);
4527
			replace(e, bro(s), scope);
4262
        retcell(s);
4528
			retcell(s);
4263
	return (1);
4529
			return(1);
4264
      };
4530
		}
4265
      return (check_seq (e, scope));
4531
		return(check_seq(e, scope));
-
 
4532
 
4266
    case cond_tag:
4533
	case cond_tag:
4267
      if (no (son (bro (son (e)))) == 0) {
4534
		if (no(son(bro(son(e)))) == 0) {
4268
	/* remove inaccessible statements */
4535
			/* remove inaccessible statements */
4269
	exp bs = bro(son(e));
4536
			exp bs = bro(son(e));
4270
#ifdef NEWDIAGS
4537
#ifdef NEWDIAGS
4271
	if (diagnose) {
4538
			if (diagnose) {
4272
	  dg_dead_code (bro(son(bs)), son(e));
4539
				dg_dead_code(bro(son(bs)), son(e));
4273
	  dg_whole_comp (e, son(e));
4540
				dg_whole_comp(e, son(e));
4274
	}
4541
			}
4275
#endif
4542
#endif
4276
	replace (e, son (e), scope);
4543
			replace(e, son(e), scope);
4277
	kill_exp(bs, scope);
4544
			kill_exp(bs, scope);
4278
	retcell(e);
4545
			retcell(e);
4279
	return (1);
4546
			return(1);
4280
      };
4547
		}
4281
      if (name (son (e)) == goto_tag &&
-
 
4282
	  pt (son (e)) == bro (son (e))) {
4548
		if (name(son(e)) == goto_tag && pt(son(e)) == bro(son(e))) {
4283
	/* replace cond which has first a simple goto to the alt by the
4549
			/* replace cond which has first a simple goto to the
4284
	   alt (removing the label) */
4550
			 * alt by the alt (removing the label) */
4285
	exp x = bro (son (bro (son (e))));
4551
			exp x = bro(son(bro(son(e))));
4286
#ifdef NEWDIAGS
4552
#ifdef NEWDIAGS
4287
	if (diagnose) {
4553
			if (diagnose) {
4288
	  dg_rdnd_code (son(e), x);
4554
				dg_rdnd_code(son(e), x);
4289
	  dg_whole_comp (e, x);
4555
				dg_whole_comp(e, x);
4290
	}
4556
			}
4291
#endif
4557
#endif
4292
	replace (e, x, scope);
4558
			replace(e, x, scope);
4293
        retcell(son (bro (son (e))));
4559
			retcell(son(bro(son(e))));
4294
	retcell(bro (son (e)));
4560
			retcell(bro(son(e)));
4295
        if (son(son(e)) != nilexp) { retcell(son(son(e))); }
4561
			if (son(son(e)) != nilexp) {
-
 
4562
				retcell(son(son(e)));
-
 
4563
			}
4296
        retcell(son(e));
4564
			retcell(son(e));
4297
        retcell(e);
4565
			retcell(e);
4298
	return (1);
4566
			return(1);
4299
      };
4567
		}
4300
 
4568
 
4301
      if (name (son (e)) == seq_tag && no (son (bro (son (e)))) == 1 &&
4569
		if (name(son(e)) == seq_tag && no(son(bro(son(e)))) == 1 &&
4302
	  name (bro (son (son (e)))) == goto_tag) {
4570
		    name(bro(son(son(e)))) == goto_tag) {
4303
	/* is e = cond(seq(..;goto m), l: x) and is only 1 use of l */
4571
			/* is e = cond(seq(..;goto m), l: x) and is only 1 use
-
 
4572
			 * of l */
4304
	exp t = son (son (son (e)));
4573
			exp t = son(son(son(e)));
4305
	while (!last (t))
4574
			while (!last(t)) {
4306
	  t = bro (t);
4575
				t = bro(t);
-
 
4576
			}
4307
#ifndef NEWDIAGS
4577
#ifndef NEWDIAGS
4308
        if (name(t) == diagnose_tag)
4578
			if (name(t) == diagnose_tag) {
4309
          t = son(t);
4579
				t = son(t);
-
 
4580
			}
4310
#endif
4581
#endif
4311
	if ((name (t) == test_tag || name (t) == testbit_tag) &&
4582
			if ((name(t) == test_tag || name(t) == testbit_tag) &&
4312
	    pt (t) == bro (son (e)) && test_number(t) <= 6) {
4583
			    pt(t) == bro(son(e)) && test_number(t) <= 6) {
4313
	  /* look at last element of sequence before goto m to see if it
4584
				/* look at last element of sequence before goto
-
 
4585
				 * m to see if it is a conditional jump to l.
4314
	     is a conditional jump to l. If so reverse the test, make it
4586
				 * If so reverse the test, make it jump to m
4315
	     jump to m and remove the goto */
4587
				 * and remove the goto */
4316
 
4588
 
4317
	  settest_number (t, revtest[test_number (t) - 1]);
4589
				settest_number(t, revtest[test_number(t) - 1]);
4318
	  pt (t) = pt (bro (son (son (e))));
4590
				pt(t) = pt(bro(son(son(e))));
4319
	  sh (son (e)) = sh (bro (son (bro (son (e)))));
4591
				sh(son(e)) = sh(bro(son(bro(son(e)))));
4320
	  replace (bro (son (son (e))),
4592
				replace(bro(son(son(e))), bro(son(bro(son(e)))),
4321
	      bro (son (bro (son (e)))),
-
 
4322
	      son (e));
4593
					son(e));
4323
	  replace (e, son (e), scope);
4594
				replace(e, son(e), scope);
4324
	  retcell (e);
4595
				retcell(e);
4325
	  return (1);
4596
				return(1);
4326
	};
4597
			}
4327
 
4598
		}
4328
      };
-
 
4329
#if maxmin_implemented
4599
#if maxmin_implemented
4330
      {
4600
		{
4331
	exp t;
4601
			exp t;
4332
	int bl = is_maxop(e, &t);
4602
			int bl = is_maxop(e, &t);
4333
	int ismax = 0;
4603
			int ismax = 0;
4334
	int ismin = 0;
4604
			int ismin = 0;
4335
	ntest nt;
4605
			ntest nt;
4336
	if (bl) {
4606
			if (bl) {
4337
	  nt = test_number(t);
4607
				nt = test_number(t);
-
 
4608
				if (nt == f_greater_than ||
4338
	  if (nt == f_greater_than || nt == f_greater_than_or_equal) {
4609
				    nt == f_greater_than_or_equal) {
4339
	    ismax = 1;
4610
					ismax = 1;
4340
	  };
4611
				}
-
 
4612
				if (nt == f_less_than ||
4341
	  if (nt == f_less_than || nt == f_less_than_or_equal)
4613
				    nt == f_less_than_or_equal) {
4342
	    ismin = 1;
4614
					ismin = 1;
4343
	}
4615
				}
4344
	else {
4616
			} else {
4345
	  bl = is_minop(e, &t);
4617
				bl = is_minop(e, &t);
4346
	  if (bl) {
4618
				if (bl) {
4347
	    nt = test_number(t);
4619
					nt = test_number(t);
-
 
4620
					if (nt == f_greater_than ||
4348
	    if (nt == f_greater_than || nt == f_greater_than_or_equal)
4621
					    nt == f_greater_than_or_equal) {
4349
	      ismin = 1;
4622
						ismin = 1;
-
 
4623
					}
-
 
4624
					if (nt == f_less_than ||
4350
	    if (nt == f_less_than || nt == f_less_than_or_equal)
4625
					    nt == f_less_than_or_equal) {
4351
	      ismax = 1;
4626
						ismax = 1;
-
 
4627
					}
4352
	  };
4628
				}
4353
	};
4629
			}
4354
	if (ismax || ismin) {
4630
			if (ismax || ismin) {
4355
	  exp tq = me_b2(copy(son(t)), copy(bro(son(t))),
4631
				exp tq = me_b2(copy(son(t)), copy(bro(son(t))),
4356
			 (ismax)
4632
					       (ismax) ?
4357
			   ? (unsigned char)max_tag
4633
					       (unsigned char)max_tag :
4358
			   : (unsigned char)min_tag);
4634
					       (unsigned char)min_tag);
4359
	  replace(e, hold_check(tq), scope);
4635
				replace(e, hold_check(tq), scope);
4360
	  kill_exp(e, e);
4636
				kill_exp(e, e);
4361
	  return 1;
4637
				return 1;
4362
	};
4638
			}
4363
      };
4639
		}
4364
#endif
4640
#endif
-
 
4641
 
-
 
4642
#if condassign_implemented
-
 
4643
		{
-
 
4644
			exp to_test;
-
 
4645
			exp to_ass;
4365
 
4646
 
-
 
4647
			if (is_condassign(e, &to_test, &to_ass) &&
-
 
4648
			    is_floating(name(sh(son(to_test)))) ==
-
 
4649
			    is_floating(name(sh(bro(son(to_ass)))))) {
-
 
4650
				exp res = me_b3(sh(e), to_test, to_ass,
4366
#if condassign_implemented
4651
						condassign_tag);
4367
      {
4652
				replace(e, res, scope);
4368
	exp to_test;
4653
				retcell(e);
4369
	exp to_ass;
4654
				return 1;
-
 
4655
			}
-
 
4656
		}
-
 
4657
#endif
4370
 
4658
 
4371
	if (is_condassign(e, &to_test, &to_ass) &&
4659
		if (name(bro(son(bro(son(e))))) == top_tag) {
-
 
4660
			exp first = son(e);
-
 
4661
			exp alt = bro(first);
-
 
4662
			int in_repeat = 0;
-
 
4663
			if (crt_repeat != nilexp &&
4372
	       is_floating(name(sh(son(to_test)))) ==
4664
			    (int)(props(crt_repeat)) == 1) {
-
 
4665
				in_repeat = 1;
-
 
4666
			}
4373
		 is_floating(name(sh(bro(son(to_ass)))))) {
4667
			if (take_out_of_line(first, alt, in_repeat, 1.0)) {
-
 
4668
				exp t = son(son(first));
4374
	  exp res = me_b3(sh(e), to_test, to_ass, condassign_tag);
4669
				exp tst = (is_tester(t, 0))? t : bro(son(t));
4375
	  replace(e, res, scope);
4670
				if (no(tst) == 1000) {
4376
	  retcell(e);
4671
					no(tst) = 25;
4377
	  return 1;
4672
				}
4378
	};
4673
			}
4379
      };
4674
		}
4380
#endif
4675
		return(0);
4381
 
4676
 
4382
      if (name(bro(son(bro(son(e))))) == top_tag) {
-
 
4383
        exp first = son(e);
-
 
4384
	exp alt = bro(first);
-
 
4385
	int in_repeat = 0;
-
 
4386
	if (crt_repeat != nilexp && (int)(props(crt_repeat)) == 1)
-
 
4387
	  in_repeat = 1;
-
 
4388
        if (take_out_of_line(first, alt, in_repeat, 1.0)) {
-
 
4389
	  exp t = son(son(first));
-
 
4390
	  exp tst = (is_tester(t, 0)) ? t : bro(son(t));
-
 
4391
	  if (no(tst) == 1000)
-
 
4392
	    no(tst) = 25;
-
 
4393
	}
-
 
4394
      }
-
 
4395
      return (0);
-
 
4396
#if condassign_implemented
4677
#if condassign_implemented
4397
    case condassign_tag:
4678
	case condassign_tag:
4398
      if (name(bro(son(e))) != ass_tag &&
4679
		if (name(bro(son(e))) != ass_tag &&
-
 
4680
		    (name(son(e)) == test_tag ||
4399
	  (name(son(e)) == test_tag || name(son(e)) == testbit_tag)) {
4681
		     name(son(e)) == testbit_tag)) {
4400
	exp sqz = me_b3(f_top, son(son(e)), bro(son(son(e))), 0);
4682
			exp sqz = me_b3(f_top, son(son(e)), bro(son(son(e))),
-
 
4683
					0);
4401
	exp sq = me_b3(sh(e), sqz, bro(son(e)), seq_tag);
4684
			exp sq = me_b3(sh(e), sqz, bro(son(e)), seq_tag);
4402
	replace(e, hold_check(sq), scope);
4685
			replace(e, hold_check(sq), scope);
4403
	retcell(e);
4686
			retcell(e);
4404
	return 1;
4687
			return 1;
4405
      };
4688
		}
4406
      if (name(son(e)) == goto_tag) {
4689
		if (name(son(e)) == goto_tag) {
4407
	replace(e, getexp(f_top, nilexp, 0, nilexp,
4690
			replace(e, getexp(f_top, nilexp, 0, nilexp, nilexp, 0,
4408
			  nilexp, 0, 0, top_tag),
-
 
4409
	        scope);
4691
					  0, top_tag), scope);
4410
	retcell(e);
4692
			retcell(e);
4411
	return 1;
4693
			return 1;
4412
      };
4694
		}
4413
      if (name(son(e)) == top_tag) {
4695
		if (name(son(e)) == top_tag) {
4414
	replace(e, bro(son(e)), scope);
4696
			replace(e, bro(son(e)), scope);
4415
	retcell(e);
4697
			retcell(e);
4416
	return 1;
4698
			return 1;
4417
      };
4699
		}
4418
#endif
4700
#endif
-
 
4701
 
-
 
4702
	case goto_tag:
4419
    case goto_tag: case return_to_label_tag: case trap_tag:
4703
	case return_to_label_tag:
-
 
4704
	case trap_tag:
4420
      return (0);
4705
		return(0);
4421
    case ass_tag:
4706
	case ass_tag:
4422
#if 0
4707
#if 0
4423
      if (0 && redo_structfns && !reg_result(sh(bro(son(e)))) &&
4708
		if (0 && redo_structfns && !reg_result(sh(bro(son(e)))) &&
4424
          name (bro (son (e))) == ident_tag &&
4709
		    name(bro(son(e))) == ident_tag &&
4425
	  isvar (bro (son (e)))) {  /* prepare to replace the assignment
4710
		    isvar (bro(son(e)))) {
4426
                                       of structure results of procedures.
4711
			/* prepare to replace the assignment of structure
4427
                                       If it decides to do so it will
4712
			 * results of procedures.  If it decides to do so it
4428
                                       put the destination in as the first
4713
			 * will put the destination in as the first parameter
4429
                                       parameter of the procedure */
4714
			 * of the procedure */
4430
	exp id = bro (son (e));
4715
			exp id = bro(son(e));
4431
	exp def = son (id);
4716
			exp def = son(id);
4432
	exp body = bro (def);
4717
			exp body = bro(def);
4433
	if (name (def) == clear_tag && name (body) == seq_tag) {
4718
			if (name(def) == clear_tag && name(body) == seq_tag) {
4434
	  if (name (son (son (body))) == apply_tag &&
4719
				if (name(son(son(body))) == apply_tag &&
4435
	      last (son (son (body))) &&
4720
				    last(son(son(body))) &&
4436
	      name (bro (son (body))) == cont_tag &&
4721
				    name(bro(son(body))) == cont_tag &&
4437
	      name (son (bro (son (body)))) == name_tag &&
4722
				    name(son(bro(son(body)))) == name_tag &&
4438
	      son (son (bro (son (body)))) == id) {
4723
				    son(son(bro(son(body)))) == id) {
4439
	    exp ap = son (son (body));
4724
					exp ap = son(son(body));
4440
	    exp p1 = bro (son (ap));
4725
					exp p1 = bro(son(ap));
4441
	    if (name (p1) == name_tag && son (p1) == id &&
4726
					if (name(p1) == name_tag &&
4442
		last (ap)) {
4727
					    son(p1) == id && last(ap)) {
4443
	      /* this is the assignment of a struct result of a proc */
4728
						/* this is the assignment of a
-
 
4729
						 * struct result of a proc */
4444
	      exp p2 = bro (son (ap));
4730
						exp p2 = bro(son(ap));
4445
	      exp se = son(e);
4731
						exp se = son(e);
4446
	      if (last(p2))
4732
						if (last(p2)) {
4447
		setlast (se);
4733
							setlast(se);
-
 
4734
						}
4448
              bro(se) = bro(p2);
4735
						bro(se) = bro(p2);
4449
              bro(son(ap)) = se;
4736
						bro(son(ap)) = se;
4450
	      if (name(se) == name_tag && isvar(son(se)) &&
4737
						if (name(se) == name_tag &&
-
 
4738
						    isvar(son(se)) &&
4451
		  !isglob(son(se)) &&
4739
						    !isglob(son(se)) &&
4452
		   shape_size(sh(id)) == shape_size(sh(son(son(se)))))
4740
						    shape_size(sh(id)) == shape_size(sh(son(son(se))))) {
4453
		setreallyass(se);
4741
							setreallyass(se);
-
 
4742
						}
4454
	      replace (e, ap, scope);
4743
						replace(e, ap, scope);
4455
	      return (1);
4744
						return(1);
4456
	    };
4745
					}
4457
	  };
4746
				}
4458
	};
4747
			}
4459
      };
4748
		}
4460
#endif
4749
#endif
4461
#ifdef promote_pars
4750
#ifdef promote_pars
-
 
4751
		{
4462
	{ int x = al1_of(sh(son(e)))->al.sh_hd;
4752
			int x = al1_of(sh(son(e)))->al.sh_hd;
4463
 
4753
 
4464
	  if (x >= scharhd && x <= uwordhd && !little_end) {
4754
			if (x >= scharhd && x <= uwordhd && !little_end) {
4465
	        exp b = bro(son(e));
4755
				exp b = bro(son(e));
4466
		int disp = shape_size(ulongsh)-((x>=swordhd)?16:8);
4756
				int disp = shape_size(ulongsh) -
-
 
4757
				    ((x >= swordhd) ? 16 : 8);
4467
		exp r = getexp(f_pointer(f_alignment(sh(b))), nilexp,
4758
				exp r = getexp(f_pointer(f_alignment(sh(b))),
-
 
4759
					       nilexp, 1, son(e), nilexp, 0,
4468
					 1, son(e), nilexp, 0, disp, reff_tag);
4760
					       disp, reff_tag);
4469
		bro(son(r)) = r; setlast(son(r));
4761
				bro(son(r)) = r; setlast(son(r));
4470
		r = hold_check(r);
4762
				r = hold_check(r);
4471
		bro(r) = b; clearlast(r);
4763
				bro(r) = b; clearlast(r);
4472
		son(e) = r;
4764
				son(e) = r;
4473
		return 1;
4765
				return 1;
4474
	  }
4766
			}
4475
	}
4767
		}
4476
#endif
4768
#endif
4477
      return (seq_distr (e, scope));
4769
		return(seq_distr(e, scope));
4478
    case testbit_tag:
-
 
4479
      {
-
 
4480
	exp arg1 = son(e);
-
 
4481
	exp arg2 = bro(arg1);
-
 
4482
	if (name (arg1) == val_tag && name (arg2) == val_tag &&
-
 
4483
		!isbigval(arg1) && !isbigval(arg2)) {
-
 
4484
	  /* evaluate if args constant */
-
 
4485
	  int  k = no (arg1) & no (arg2);
-
 
4486
	  if ((k != 0 && test_number (e) == 5) ||
-
 
4487
                   (k == 0 && test_number (e) == 6))
-
 
4488
	    repbygo (e, pt (e), scope);
-
 
4489
	  else
-
 
4490
	    repbycont (e, 1, scope);
-
 
4491
	  return (1);
-
 
4492
	};
-
 
4493
	if (name(arg1) == shr_tag && name(arg2) == val_tag &&
-
 
4494
		name(bro(son(arg1))) == val_tag &&
-
 
4495
		!isbigval(arg2) && !isbigval(bro(son(arg1)))) {
-
 
4496
	  exp x = son(arg1);
-
 
4497
	  exp nsh = bro(x);
-
 
4498
	  int places = no(nsh);
-
 
4499
	  exp res;
-
 
4500
	  sh(x) = sh(arg2);
-
 
4501
	  res = me_b3(sh(e), x, me_shint(sh(arg2), no(arg2) << places),
-
 
4502
				testbit_tag);
-
 
4503
	  no(res) = no(e);
-
 
4504
	  pt(res) = pt(e);
-
 
4505
	  settest_number(res, test_number(e));
-
 
4506
	  replace(e, hold_check(res), scope);
-
 
4507
	  retcell(e);
-
 
4508
	  return 1;
-
 
4509
	};
-
 
4510
	return (0);
-
 
4511
      };
-
 
4512
    case test_tag: {
-
 
4513
	exp arg1, arg2;
-
 
4514
	int  n;
-
 
4515
	int bl;
-
 
4516
        unsigned char nt = test_number(e);
-
 
4517
	arg1 = son (e);
-
 
4518
	arg2 = bro (arg1);
-
 
4519
 
4770
 
-
 
4771
	case testbit_tag: {
-
 
4772
		exp arg1 = son(e);
-
 
4773
		exp arg2 = bro(arg1);
-
 
4774
		if (name(arg1) == val_tag && name(arg2) == val_tag &&
-
 
4775
		    !isbigval(arg1) && !isbigval(arg2)) {
-
 
4776
			/* evaluate if args constant */
-
 
4777
			int k = no(arg1) & no(arg2);
-
 
4778
			if ((k != 0 && test_number(e) == 5) ||
-
 
4779
			    (k == 0 && test_number(e) == 6)) {
-
 
4780
				repbygo(e, pt(e), scope);
-
 
4781
			} else {
-
 
4782
				repbycont(e, 1, scope);
-
 
4783
			}
-
 
4784
			return(1);
-
 
4785
		}
-
 
4786
		if (name(arg1) == shr_tag && name(arg2) == val_tag &&
-
 
4787
		    name(bro(son(arg1))) == val_tag &&
-
 
4788
		    !isbigval(arg2) && !isbigval(bro(son(arg1)))) {
-
 
4789
			exp x = son(arg1);
-
 
4790
			exp nsh = bro(x);
-
 
4791
			int places = no(nsh);
-
 
4792
			exp res;
-
 
4793
			sh(x) = sh(arg2);
-
 
4794
			res = me_b3(sh(e), x,
-
 
4795
				    me_shint(sh(arg2), no(arg2) << places),
-
 
4796
				    testbit_tag);
-
 
4797
			no(res) = no(e);
-
 
4798
			pt(res) = pt(e);
-
 
4799
			settest_number(res, test_number(e));
-
 
4800
			replace(e, hold_check(res), scope);
-
 
4801
			retcell(e);
-
 
4802
			return 1;
-
 
4803
		}
-
 
4804
		return(0);
-
 
4805
	}
-
 
4806
 
-
 
4807
	case test_tag: {
-
 
4808
		exp arg1, arg2;
-
 
4809
		int n;
-
 
4810
		int bl;
-
 
4811
		unsigned char nt = test_number(e);
-
 
4812
		arg1 = son(e);
-
 
4813
		arg2 = bro(arg1);
-
 
4814
 
4520
        if (flpt_always_comparable ||
4815
		if (flpt_always_comparable ||
4521
             (name(sh(arg1)) < shrealhd || name(sh(arg1)) > doublehd)) {
4816
		    (name(sh(arg1)) < shrealhd || name(sh(arg1)) > doublehd)) {
4522
          switch (nt) {
4817
			switch (nt) {
-
 
4818
			case 7:
4523
            case 7: nt = f_greater_than;
4819
				nt = f_greater_than;
4524
		    break;
4820
				break;
-
 
4821
			case 8:
4525
            case 8: nt = f_greater_than_or_equal;
4822
				nt = f_greater_than_or_equal;
4526
		    break;
4823
				break;
-
 
4824
			case 9:
4527
            case 9: nt = f_less_than;
4825
				nt = f_less_than;
4528
		    break;
4826
				break;
-
 
4827
			case 10:
4529
            case 10: nt = f_less_than_or_equal;
4828
				nt = f_less_than_or_equal;
4530
		     break;
4829
				break;
-
 
4830
			case 11:
4531
            case 11: nt = f_not_equal;
4831
				nt = f_not_equal;
4532
		     break;
4832
				break;
-
 
4833
			case 12:
4533
            case 12: nt = f_equal;
4834
				nt = f_equal;
4534
		     break;
4835
				break;
-
 
4836
			case 13:
4535
            case 13: repbycont (e, 1, scope);
4837
				repbycont(e, 1, scope);
4536
		     return 1;
4838
				return 1;
-
 
4839
			case 14:
4537
            case 14: repbygo (e, pt (e), scope);
4840
				repbygo(e, pt(e), scope);
4538
		     return 1;
4841
				return 1;
4539
	    default: break;
4842
			default:
4540
          };
4843
				break;
4541
        };
4844
			}
-
 
4845
		}
4542
 
4846
 
4543
	settest_number(e, nt);
4847
		settest_number(e, nt);
4544
 
4848
 
4545
		/* evaluate constant expressions */
4849
		/* evaluate constant expressions */
4546
 
4850
 
4547
	if ((name (arg1) == val_tag || name (arg1) == null_tag) &&
4851
		if ((name(arg1) == val_tag || name(arg1) == null_tag) &&
4548
	    (name (arg2) == val_tag || name (arg2) == null_tag)) {
4852
		    (name(arg2) == val_tag || name(arg2) == null_tag)) {
4549
	  /* see if we know which way to jump and replace by unconditional
4853
			/* see if we know which way to jump and replace by
4550
	     goto or nop. For integers. */
4854
			 * unconditional goto or nop. For integers. */
4551
	  int c = docmp_f ((int)test_number (e), arg1, arg2);
4855
			int c = docmp_f((int)test_number(e), arg1, arg2);
4552
 
4856
 
4553
	  if (c)
4857
			if (c) {
4554
	    repbycont (e, 1, scope);
4858
				repbycont(e, 1, scope);
4555
	  else
4859
			} else {
4556
	    repbygo (e, pt (e), scope);
4860
				repbygo(e, pt(e), scope);
-
 
4861
			}
4557
	  return (1);
4862
			return(1);
4558
	};
4863
		}
4559
        if (test_number (e) >= 5 &&
4864
		if (test_number(e) >= 5 &&
4560
            ((name(arg1) == null_tag && no(arg1) == 0 &&
4865
		    ((name(arg1) == null_tag && no(arg1) == 0 &&
4561
		name(arg2) == name_tag &&
4866
		      name(arg2) == name_tag && isvar(son(arg2))) ||
4562
		isvar(son(arg2))) ||
-
 
4563
            (name(arg2) == null_tag && no(arg2) == 0 &&
4867
		     (name(arg2) == null_tag && no(arg2) == 0 &&
4564
		name(arg1) == name_tag &&
4868
		      name(arg1) == name_tag && isvar(son(arg1))))) {
4565
		isvar(son(arg1)))))  {
-
 
4566
		/* if we are comparing null with a variable we
4869
			/* if we are comparing null with a variable we
4567
		   know the way to jump. */
4870
			   know the way to jump. */
4568
          if (test_number(e) == 6)
4871
			if (test_number(e) == 6) {
4569
             repbycont(e, 1, scope);
4872
				repbycont(e, 1, scope);
4570
          else
4873
			} else {
4571
             repbygo(e, pt(e), scope);
4874
				repbygo(e, pt(e), scope);
-
 
4875
			}
4572
          return 1;
4876
			return 1;
4573
        };
4877
		}
4574
	if (name (arg1) == real_tag && name (arg2) == real_tag &&
4878
		if (name(arg1) == real_tag && name(arg2) == real_tag &&
4575
	     test_number(e) <= 6) {
4879
		    test_number(e) <= 6) {
4576
	  /* similar for reals */
4880
			/* similar for reals */
4577
	  if (cmpflpt (no (arg1), no (arg2), (int)(test_number (e))))
4881
			if (cmpflpt(no(arg1), no(arg2),
-
 
4882
				    (int)(test_number(e)))) {
4578
	    repbycont (e, 1, scope);
4883
				repbycont(e, 1, scope);
4579
	  else
4884
			} else {
4580
	    repbygo (e, pt (e), scope);
4885
				repbygo(e, pt(e), scope);
-
 
4886
			}
4581
	  return (1);
4887
			return(1);
4582
	};
4888
		}
4583
 
4889
 
4584
		/* end of constant expression evaluation */
4890
		/* end of constant expression evaluation */
4585
 
-
 
4586
	if (name(arg1) == val_tag || name(arg1) == real_tag ||
-
 
4587
		name(arg1) == null_tag) {
-
 
4588
		/* constant argument always second */
-
 
4589
	  son(e) = arg2;
-
 
4590
	  bro(arg2) = arg1;
-
 
4591
	  bro(arg1) = e;
-
 
4592
	  setlast(arg1);
-
 
4593
	  clearlast(arg2);
-
 
4594
	  arg2 = arg1;
-
 
4595
	  arg1 = son(e);
-
 
4596
	  nt = exchange_ntest[nt];
-
 
4597
	  settest_number(e, nt);
-
 
4598
	};
-
 
4599
 
4891
 
-
 
4892
		if (name(arg1) == val_tag || name(arg1) == real_tag ||
-
 
4893
		    name(arg1) == null_tag) {
-
 
4894
			/* constant argument always second */
-
 
4895
			son(e) = arg2;
-
 
4896
			bro(arg2) = arg1;
-
 
4897
			bro(arg1) = e;
-
 
4898
			setlast(arg1);
-
 
4899
			clearlast(arg2);
-
 
4900
			arg2 = arg1;
-
 
4901
			arg1 = son(e);
-
 
4902
			nt = exchange_ntest[nt];
-
 
4903
			settest_number(e, nt);
-
 
4904
		}
-
 
4905
 
4600
	if (name (arg1) == chvar_tag && name (arg2) == chvar_tag &&
4906
		if (name(arg1) == chvar_tag && name(arg2) == chvar_tag &&
4601
	    name (sh (son (arg1))) == name (sh (son (arg2))) &&
4907
		    name(sh(son(arg1))) == name(sh(son(arg2))) &&
4602
	    shape_size (sh (son (arg1))) <= shape_size (sh (arg1)) &&
4908
		    shape_size(sh(son(arg1))) <= shape_size(sh(arg1)) &&
4603
 
4909
 
4604
#if only_lengthen_ops
4910
#if only_lengthen_ops
4605
	    shape_size(sh (arg1)) >= 16 &&
4911
		    shape_size(sh(arg1)) >= 16 &&
4606
#endif
4912
#endif
4607
	    (is_signed(sh (son (arg1))) == is_signed(sh (arg1)))
4913
		    (is_signed(sh(son(arg1))) == is_signed(sh(arg1)))) {
4608
	  ) {
-
 
4609
	  exp ee;
4914
			exp ee;
4610
#if is80x86 || ishppa
4915
#if is80x86 || ishppa
4611
	/* optimise if both args are result of sign extension removal */
4916
			/* optimise if both args are result of sign extension
-
 
4917
			 * removal */
4612
	    if ((test_number(e) == f_equal ||
4918
			if ((test_number(e) == f_equal ||
4613
			 test_number(e) == f_not_equal) &&
4919
			     test_number(e) == f_not_equal) &&
4614
		name(sh(arg1)) == slonghd &&
4920
			    name(sh(arg1)) == slonghd &&
4615
		name(son(arg1)) == cont_tag &&
4921
			    name(son(arg1)) == cont_tag &&
4616
		name(son(arg2)) == cont_tag &&
4922
			    name(son(arg2)) == cont_tag &&
4617
		shape_size(sh (son(arg1))) == 16 &&
4923
			    shape_size(sh(son(arg1))) == 16 &&
4618
		name(son(son(arg1))) == name_tag &&
4924
			    name(son(son(arg1))) == name_tag &&
4619
		name(son(son(arg2))) == name_tag) {
4925
			    name(son(son(arg2))) == name_tag) {
4620
	      exp dec1 = son(son(son(arg1)));
4926
				exp dec1 = son(son(son(arg1)));
4621
	      exp dec2 = son(son(son(arg2)));
4927
				exp dec2 = son(son(son(arg2)));
4622
	      if (isse_opt(dec1) && isse_opt(dec2)) {
4928
				if (isse_opt(dec1) && isse_opt(dec2)) {
4623
		son(e) = son(arg1);
4929
					son(e) = son(arg1);
4624
		sh(son(arg1)) = slongsh;
4930
					sh(son(arg1)) = slongsh;
4625
		clearlast(son(arg1));
4931
					clearlast(son(arg1));
4626
		bro(son(arg1)) = son(arg2);
4932
					bro(son(arg1)) = son(arg2);
4627
		sh(son(arg2)) = slongsh;
4933
					sh(son(arg2)) = slongsh;
4628
		setlast(son(arg2));
4934
					setlast(son(arg2));
4629
		bro(son(arg2)) = e;
4935
					bro(son(arg2)) = e;
4630
		return 0;
4936
					return 0;
4631
	      };
4937
				}
4632
	    };
4938
			}
4633
#endif
4939
#endif
4634
	  /* arrange to do test in smallest size integers by removing
4940
			/* arrange to do test in smallest size integers by
4635
	     chvar and altering shape of test args */
4941
			 * removing chvar and altering shape of test args */
4636
	  ee = copyexp (e);
4942
			ee = copyexp(e);
4637
	  son (ee) = son (arg1);
4943
			son(ee) = son(arg1);
4638
	  bro (son (arg1)) = son (arg2);
4944
			bro(son(arg1)) = son(arg2);
4639
	  clearlast (son (arg1));
4945
			clearlast(son(arg1));
4640
	  replace (e, hc (ee, bro (son (ee))), scope);
4946
			replace(e, hc(ee, bro(son(ee))), scope);
4641
	  retcell (arg1);
4947
			retcell(arg1);
4642
	  retcell (arg2);
4948
			retcell(arg2);
4643
	  retcell (e);
4949
			retcell(e);
4644
	  return (1);
4950
			return(1);
4645
	};
4951
		}
4646
#if little_end & has_byte_ops
4952
#if little_end & has_byte_ops
4877
#ifdef NEWDIAGS
5186
#ifdef NEWDIAGS
4878
	    if (diagnose)
5187
				if (diagnose) {
4879
	      dg_dead_code (bro(son(q)), t);
5188
					dg_dead_code(bro(son(q)), t);
-
 
5189
				}
4880
#endif
5190
#endif
4881
	    kill_exp (q, q);
5191
				kill_exp(q, q);
4882
	    looping = !last(t);
5192
				looping = !last(t);
4883
	  }
-
 
4884
	  else {
5193
			} else {
4885
	    looping = !last (bro (t));
5194
				looping = !last(bro(t));
4886
	    t = bro (t);
5195
				t = bro(t);
4887
	  };
-
 
4888
	}
5196
			}
4889
	while (looping);
5197
		} while (looping);
4890
 
5198
 
4891
	if (last (son (e))) {
5199
		if (last(son(e))) {
4892
#ifdef NEWDIAGS
5200
#ifdef NEWDIAGS
4893
	  if (diagnose)
5201
			if (diagnose) {
4894
	    dg_whole_comp (e, son(e));
5202
				dg_whole_comp(e, son(e));
-
 
5203
			}
4895
#endif
5204
#endif
4896
	  replace (e, copy(son (e)), scope);
5205
			replace(e, copy(son(e)), scope);
4897
	  kill_exp(e,e);
5206
			kill_exp(e, e);
-
 
5207
			return(1);
-
 
5208
		}
-
 
5209
 
-
 
5210
		if (changed) {
4898
	  return (1);
5211
			return(1);
-
 
5212
		}
-
 
5213
		return(0);
4899
	};
5214
	}
-
 
5215
 
-
 
5216
	case case_tag:
-
 
5217
		if (name(son(e)) == val_tag) {
-
 
5218
			/* if we know the case argument select the right case
-
 
5219
			 * branch and replace by goto. Knock on effect will be
-
 
5220
			 * to eliminate dead code. */
-
 
5221
			exp n = son(e);
-
 
5222
			int changed = 0;
-
 
5223
			exp t = son(e);
-
 
5224
			exp z;
-
 
5225
			do {
-
 
5226
				exp up;
-
 
5227
				t = bro(t);
-
 
5228
				if (son(t) == nilexp) {
-
 
5229
					up = t;
-
 
5230
				} else {
-
 
5231
					up = son(t);
-
 
5232
				}
-
 
5233
 
-
 
5234
				if (docmp_f((int)f_less_than_or_equal, t, n) &&
-
 
5235
				    docmp_f((int)f_less_than_or_equal, n, up)) {
-
 
5236
					changed = 1;
-
 
5237
					z = pt(t);
-
 
5238
				}
-
 
5239
				/*	  else
-
 
5240
					  --no(son(pt(t)));
-
 
5241
				 */
-
 
5242
			} while (!last(t));
-
 
5243
 
-
 
5244
			if (!changed) {
-
 
5245
				repbycont(e, 0, scope);
-
 
5246
			} else {
-
 
5247
				SET(z);
-
 
5248
				repbygo(e, z, scope);
-
 
5249
			}
-
 
5250
			return(1);
-
 
5251
		}
-
 
5252
		return(0);
-
 
5253
		
-
 
5254
	case rep_tag:
-
 
5255
	case apply_general_tag:
-
 
5256
	case set_stack_limit_tag:
-
 
5257
	case give_stack_limit_tag:
-
 
5258
	case env_size_tag:
-
 
5259
	case apply_tag:
-
 
5260
	case res_tag:
-
 
5261
	case goto_lv_tag:
-
 
5262
	case assvol_tag:
-
 
5263
	case local_free_all_tag:
-
 
5264
	case local_free_tag:
-
 
5265
	case last_local_tag:
-
 
5266
	case long_jump_tag:
-
 
5267
	case movecont_tag:
-
 
5268
		return(0);
-
 
5269
		
-
 
5270
	case alloca_tag:
-
 
5271
		if (name(son(e)) == chvar_tag &&
-
 
5272
		    name(sh(son(son(e)))) == ulonghd) {
-
 
5273
			replace(son(e), son(son(e)), son(e));
-
 
5274
		}
-
 
5275
		return(0);
-
 
5276
		
-
 
5277
	case nof_tag:
-
 
5278
	case labst_tag:
-
 
5279
		return 0;
-
 
5280
 
-
 
5281
	case concatnof_tag: {
-
 
5282
		exp a1 = son(e);
-
 
5283
		exp a2 = bro(a1);
-
 
5284
		exp r;
-
 
5285
		nat n;
-
 
5286
		if (name(a1) == string_tag && name(a2) == string_tag) {
-
 
5287
			/* apply if args constant */
-
 
5288
			char *s1 = nostr(son(e));
-
 
5289
			char *s2 = nostr(bro(son(e)));
-
 
5290
			/* note NOT zero termination convention !! */
-
 
5291
			int sz1, sz2, i;
-
 
5292
			char *newstr;
-
 
5293
			char *p2;
-
 
5294
			shape newsh;
-
 
5295
			sz1 = shape_size(sh(son(e))) / 8;
-
 
5296
			sz2 = shape_size(sh(bro(son(e)))) / 8;
-
 
5297
			newstr = (char *)xcalloc((sz1 + sz2), sizeof(char));
-
 
5298
			p2 = &newstr[sz1];
-
 
5299
			nat_issmall(n) = 1;
-
 
5300
			natint(n) = sz1 + sz2;
-
 
5301
			newsh = f_nof(n, scharsh);
-
 
5302
			for (i = 0; i < sz1; ++i) {
-
 
5303
				newstr[i] = s1[i];
-
 
5304
			}
-
 
5305
			for (i = 0; i < sz2; ++i) {
-
 
5306
				p2[i] = s2[i];
-
 
5307
			}
-
 
5308
			r = getexp(newsh, nilexp, 0, nilexp, nilexp, 0, 0,
-
 
5309
				   string_tag);
-
 
5310
			nostr(r) = newstr;
-
 
5311
			replace(e, r, scope);
-
 
5312
			kill_exp(e, scope);
-
 
5313
			return(1);
-
 
5314
		}
-
 
5315
		return 0;
-
 
5316
	}
-
 
5317
 
-
 
5318
	case ncopies_tag:
-
 
5319
	case ignorable_tag:
-
 
5320
		return 0;
4900
 
5321
 
4901
	if (changed)
5322
	case bfass_tag:
-
 
5323
	case bfassvol_tag: {
4902
	  return (1);
5324
		exp p = son(e);
4903
	return (0);
5325
		exp val = bro(p);
-
 
5326
		int bsz = shape_size(sh(val));
4904
      };
5327
		int rsz;
4905
    case case_tag:
5328
		int rsh;
4906
      if (name (son (e)) == val_tag ) {
5329
		int sg = is_signed(sh(val));
4907
	/* if we know the case argument select the right case branch and
-
 
4908
	   replace by goto. Knock on effect will be to eliminate dead
-
 
4909
	   code. */
5330
		int posmask;
4910
	exp  n = son (e);
5331
		int negmask;
4911
	int changed = 0;
5332
		int off = no(e);
4912
	exp t = son (e);
5333
		exp ref;
4913
	exp z;
5334
		exp cont;
4914
	do {
5335
		exp eshift;
4915
	  exp  up;
5336
		exp res;
4916
	  t = bro (t);
5337
		exp id;
4917
	  if (son (t) == nilexp)
5338
		exp idval;
4918
	    up = t;
5339
		shape ptr_sha;
4919
	  else
5340
		shape msh;
4920
	    up = son (t);
5341
		int temp = off + bsz - 1;
4921
 
5342
 
4922
	  if (docmp_f((int)f_less_than_or_equal, t, n) &&
-
 
4923
		docmp_f((int)f_less_than_or_equal, n, up)) {
-
 
4924
	    changed = 1;
-
 
4925
	    z = pt(t);
-
 
4926
	  }
-
 
4927
/*	  else
-
 
4928
	    --no (son (pt (t)));
-
 
4929
*/
-
 
4930
	}
-
 
4931
	while (!last (t));
-
 
4932
 
-
 
4933
	if (!changed)
-
 
4934
	  repbycont (e, 0, scope);
-
 
4935
	else {
-
 
4936
	  SET(z);
-
 
4937
	  repbygo (e, z, scope);
-
 
4938
	};
-
 
4939
	return (1);
-
 
4940
      };
-
 
4941
      return (0);
-
 
4942
    case rep_tag:
-
 
4943
    case apply_general_tag:
-
 
4944
    case set_stack_limit_tag:
-
 
4945
    case give_stack_limit_tag:
-
 
4946
    case env_size_tag:
-
 
4947
    case apply_tag:
-
 
4948
    case res_tag:
-
 
4949
    case goto_lv_tag:
-
 
4950
    case assvol_tag:
-
 
4951
    case local_free_all_tag:
-
 
4952
    case local_free_tag:
-
 
4953
    case last_local_tag:
-
 
4954
    case long_jump_tag:
-
 
4955
    case movecont_tag:
-
 
4956
      return (0);
-
 
4957
    case alloca_tag:
-
 
4958
      if (name(son(e)) == chvar_tag && name(sh(son(son(e)))) == ulonghd) {
-
 
4959
	replace(son(e), son(son(e)), son(e));
-
 
4960
      };
-
 
4961
      return (0);
-
 
4962
    case nof_tag:
-
 
4963
    case labst_tag:
-
 
4964
      return 0;
-
 
4965
    case concatnof_tag:
-
 
4966
	{
-
 
4967
	  exp a1 = son (e);
-
 
4968
	  exp a2 = bro (a1);
-
 
4969
          exp r;
-
 
4970
          nat n;
-
 
4971
	  if (name (a1) == string_tag &&
-
 
4972
	      name (a2) == string_tag) {
-
 
4973
	    /* apply if args constant */
-
 
4974
	    char *s1 = nostr(son(e));
-
 
4975
	    char *s2 = nostr(bro(son(e)));
-
 
4976
	    /* note NOT zero termination convention !! */
-
 
4977
	    int  sz1,
-
 
4978
	          sz2,
-
 
4979
	          i;
-
 
4980
	    char * newstr;
-
 
4981
	    char * p2;
-
 
4982
	    shape newsh;
-
 
4983
	    sz1 = shape_size(sh(son(e)))/8;
-
 
4984
	    sz2 = shape_size(sh(bro (son (e))))/8;
-
 
4985
	    newstr = (char *) xcalloc ( (sz1 + sz2), sizeof (char));
-
 
4986
	    p2 = &newstr[sz1];
-
 
4987
            nat_issmall(n) = 1;
-
 
4988
            natint(n) = sz1+sz2;
-
 
4989
	    newsh = f_nof (n, scharsh);
-
 
4990
	    for (i = 0; i < sz1; ++i)
-
 
4991
	      newstr[i] = s1[i];
-
 
4992
	    for (i = 0; i < sz2; ++i)
-
 
4993
	      p2[i] = s2[i];
-
 
4994
            r = getexp (newsh, nilexp, 0, nilexp,
-
 
4995
		     nilexp, 0, 0, string_tag);
-
 
4996
            nostr(r) = newstr;
-
 
4997
	    replace (e, r, scope);
-
 
4998
	    kill_exp (e, scope);
-
 
4999
	    return (1);
-
 
5000
	  };
-
 
5001
	  return 0;
-
 
5002
	};
-
 
5003
    case ncopies_tag:
-
 
5004
    case ignorable_tag:
-
 
5005
	return 0;
-
 
5006
    case bfass_tag:
-
 
5007
    case bfassvol_tag:
-
 
5008
	{
-
 
5009
	  exp p = son(e);
-
 
5010
	  exp val = bro(p);
-
 
5011
	  int bsz = shape_size(sh(val));
-
 
5012
	  int rsz;
-
 
5013
	  int rsh;
-
 
5014
	  int sg = is_signed(sh(val));
-
 
5015
	  int posmask;
-
 
5016
	  int negmask;
-
 
5017
	  int off = no(e);
-
 
5018
	  exp ref;
-
 
5019
	  exp cont;
-
 
5020
	  exp eshift;
-
 
5021
	  exp res;
-
 
5022
	  exp id;
-
 
5023
	  exp idval;
-
 
5024
	  shape ptr_sha;
-
 
5025
	  shape msh;
-
 
5026
	  int temp = off + bsz - 1;
-
 
5027
 
-
 
5028
	  if (((off/8) == (temp/8)) && bsz<=8
5343
		if (((off / 8) == (temp / 8)) && bsz <= 8
5029
#if 0
5344
#if 0
5030
		(bsz == 8 &&
5345
		    (bsz == 8 &&
5031
		    ((little_end && (off%8 == 0)) ||
5346
		     ((little_end && (off%8 == 0)) ||
5032
		      (!little_end && ((8 - (off % 8) - bsz) == 0))))
5347
		      (!little_end && ((8 - (off % 8) - bsz) == 0))))
5033
#endif
5348
#endif
5034
	        ) {
5349
		   ) {
5035
	    rsz = 8;
5350
			rsz = 8;
5036
	    if (sg)
5351
			if (sg) {
5037
	      msh = scharsh;
5352
				msh = scharsh;
5038
	    else
5353
			} else {
5039
	      msh = ucharsh;
5354
				msh = ucharsh;
5040
	  }
5355
			}
5041
	  else
-
 
5042
	  if (((off/16) == (temp/16)) && bsz <= 16
5356
		} else if (((off / 16) == (temp / 16)) && bsz <= 16
5043
#if 0
5357
#if 0
5044
	        (bsz == 16 &&
5358
			   (bsz == 16 &&
5045
		   ((little_end && (off%16 == 0)) ||
5359
			    ((little_end && (off%16 == 0)) ||
5046
		     (!little_end && ((16 - (off % 16) - bsz) == 0))))
5360
			     (!little_end && ((16 - (off % 16) - bsz) == 0))))
5047
#endif
5361
#endif
5048
              ) {
5362
			  ) {
5049
	    rsz = 16;
5363
			rsz = 16;
5050
	    if (sg)
5364
			if (sg) {
5051
	      msh = swordsh;
5365
				msh = swordsh;
5052
	    else
5366
			} else {
5053
	      msh = uwordsh;
5367
				msh = uwordsh;
5054
	  }
5368
			}
5055
	  else
-
 
5056
	  if ((off/32) == (temp/32)) {
5369
		} else if ((off / 32) == (temp / 32)) {
5057
	    rsz = 32;
5370
			rsz = 32;
5058
	    if (sg)
5371
			if (sg) {
5059
	      msh = slongsh;
5372
				msh = slongsh;
5060
	    else
5373
			} else {
5061
	      msh = ulongsh;
5374
				msh = ulongsh;
5062
	  }
5375
			}
5063
	  else {
5376
		} else {
5064
	    rsz = 64;
5377
			rsz = 64;
5065
	    if (sg)
5378
			if (sg) {
5066
	      msh = s64sh;
5379
				msh = s64sh;
5067
	    else
5380
			} else {
5068
	      msh = u64sh;
5381
				msh = u64sh;
5069
	  };
5382
			}
-
 
5383
		}
5070
	  ptr_sha = f_pointer(long_to_al(rsz));
5384
		ptr_sha = f_pointer(long_to_al(rsz));
5071
 
5385
 
5072
	  if ((off / rsz) != 0) {
5386
		if ((off / rsz) != 0) {
5073
	    ref = me_u3(ptr_sha, p, reff_tag);
5387
			ref = me_u3(ptr_sha, p, reff_tag);
5074
	    no(ref) = (off / rsz) * rsz;
5388
			no(ref) = (off / rsz) * rsz;
5075
	    ref = hold_check(ref);
5389
			ref = hold_check(ref);
5076
	  }
-
 
5077
	  else
5390
		} else {
5078
	    ref = p;
5391
			ref = p;
-
 
5392
		}
5079
	  id = me_startid(f_top, ref, 0);
5393
		id = me_startid(f_top, ref, 0);
5080
#if little_end
5394
#if little_end
5081
	  rsh = off % rsz;
5395
		rsh = off % rsz;
5082
#else
5396
#else
5083
	  rsh = rsz - (off % rsz) - bsz;
5397
		rsh = rsz - (off % rsz) - bsz;
5084
#endif
5398
#endif
5085
	  posmask = (bsz == 32) ? -1 : (1 << bsz) -1;
5399
		posmask = (bsz == 32) ? -1 : (1 << bsz) -1;
5086
	  negmask = ~(posmask << rsh);
5400
		negmask = ~(posmask << rsh);
5087
	  cont = me_u3(msh, me_obtain(id),
5401
		cont = me_u3(msh, me_obtain(id), (name(e) == bfass_tag) ?
5088
		        (name(e) == bfass_tag)
-
 
5089
			  ? (unsigned char)cont_tag
5402
			     (unsigned char)cont_tag :
5090
			  : (unsigned char)contvol_tag);
5403
			     (unsigned char)contvol_tag);
5091
	  val = hold_check(me_u3(msh, val, chvar_tag));
5404
		val = hold_check(me_u3(msh, val, chvar_tag));
5092
	  val = hold_check(me_b3(msh, val,
5405
		val = hold_check(me_b3(msh, val, me_shint(msh, posmask),
5093
				 me_shint(msh, posmask), and_tag));
5406
				       and_tag));
5094
	  if (rsh != 0)
5407
		if (rsh != 0) {
5095
	    eshift =
-
 
5096
	     hold_check(me_b3(msh, val, me_shint(slongsh, rsh), shl_tag));
5408
			eshift = hold_check(me_b3(msh, val, me_shint(slongsh,
-
 
5409
								rsh), shl_tag));
5097
	  else {
5410
		} else {
5098
	    eshift = val;
5411
			eshift = val;
5099
	    sh(eshift) = msh;
5412
			sh(eshift) = msh;
5100
	  };
5413
		}
5101
	  idval = me_startid(f_top, eshift, 0);
5414
		idval = me_startid(f_top, eshift, 0);
5102
 
5415
 
5103
	  if (rsz != bsz) {
5416
		if (rsz != bsz) {
5104
	    cont = me_b3(msh, cont, me_shint(msh, negmask), and_tag);
5417
			cont = me_b3(msh, cont, me_shint(msh, negmask),
-
 
5418
				     and_tag);
5105
	    cont = hold_check(me_b3(msh, cont, me_obtain(idval), or_tag));
5419
			cont = hold_check(me_b3(msh, cont, me_obtain(idval),
5106
	  }
5420
						or_tag));
5107
	  else {
5421
		} else {
5108
	    kill_exp(cont, cont);
5422
			kill_exp(cont, cont);
5109
	    cont = me_obtain(idval);
5423
			cont = me_obtain(idval);
5110
	  };
5424
		}
5111
	  res = me_b3(f_top, me_obtain(id), cont,
5425
		res = me_b3(f_top, me_obtain(id), cont,
5112
		      (name(e) == bfass_tag)
-
 
5113
		        ? (unsigned char)ass_tag
5426
			    (name(e) == bfass_tag) ? (unsigned char)ass_tag :
5114
			: (unsigned char)assvol_tag);
5427
			    (unsigned char)assvol_tag);
5115
	  res = hold_check(me_complete_id(idval, res));
5428
		res = hold_check(me_complete_id(idval, res));
5116
	  replace(e, hold_check(me_complete_id(id, res)), scope);
5429
		replace(e, hold_check(me_complete_id(id, res)), scope);
5117
	  retcell(e);
5430
		retcell(e);
5118
	  return 1;
5431
		return 1;
5119
	};
5432
	}
5120
    default:
5433
	default:
5121
      return (0);
5434
		return(0);
5122
  }
5435
	}
5123
}
5436
}