misc.lsp 345 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Sep 20 09:45:15 2003
;;;; Contains: Miscellaneous tests

;;;
;;; This file contains odds-and-ends, mostly tests that came up as
;;; bug-stimulators in various implementations.
;;;

(in-package :cl-test)

13
14
(declaim (special *s1* *s2* *s3* *s4* *s5* *s6* *s7* *s8*))

15
16
(deftest misc.1
  (funcall
pfdietz's avatar
pfdietz committed
17
   (compile nil '(lambda (b)
18
19
                   (declare (type (integer 8 22337) b))
                   (+ b 2607688420)))
20
21
22
23
24
   100)
  2607688520)

(deftest misc.2
  (funcall (compile nil
25
26
                    '(lambda (b) (integer-length (dpb b (byte 4 28) -1005))))
           12800263)
27
28
29
30
31
32
33
34
35
  32)

(deftest misc.3
  (funcall
   (compile
    nil
    '(lambda (a b)
       (declare (optimize (speed 3) (debug 1)))
       (let ((v7
36
37
38
              (let ((v2 (block b5 (return-from b5 (if t b -4)))))
                a)))
         -65667836)))
39
40
41
42
43
44
45
46
   1 2)
  -65667836)

(deftest misc.4
  (funcall
   (compile
    nil
    '(lambda (a b c)
47
48
49
50
51
52
           (declare (type (integer -629491 -333) a)
                    (type (integer -142 1) b)
                    (type (integer 0 12604) c)
                    (optimize (speed 3) (safety 1) (debug 1)))
           (let ((v6 (block b7 (return-from b7 (if (eql b 0) 1358159 a)))))
                b)))
53
54
55
56
57
58
   -1000 -17 6143)
  -17)

(deftest misc.5
  (funcall
   (compile nil
59
60
            '(lambda () (* 390 (- (signum (logeqv -8005440 -2310))
                                  -10604863)))))
61
62
63
64
65
  4135896180)

(deftest misc.6
  (funcall
   (compile nil
66
67
68
69
70
71
            '(lambda (a c)
                     (declare (optimize (speed 3) (debug 1)))
                     (flet ((%f14 () (if c a -486826646)))
                           (let ((v7 (flet ((%f18 () (%f14))) a)))
                                (let ((v5 (%f14)))
                                     0)))))
72
73
74
75
76
   10 20)
  0)

(deftest misc.7
  (funcall (compile nil
77
78
79
80
81
82
                    '(lambda (c) (declare (optimize (speed 3) (debug 1)))
                       (flet ((%f18 () -36))
                         (flet ((%f13 ()
                                      (let () (block b8 (return-from b8 c)))))
                           (%f18)))))
           10)
83
84
85
86
87
88
89
90
91
  -36)

(deftest misc.8
  (funcall
   (compile
    nil
    '(lambda (a b)
       (declare (optimize (speed 3) (debug 1)))
       (let ((v3 (flet ((%f12 () (min b (block b2 (return-from b2 a)))))
92
93
94
95
                       a)))
            (block b7
                   (flet ((%f5 () (return-from b7 b)))
                         (%f5))))))
96
97
98
99
100
101
102
103
   10 20)
  20)

(deftest misc.9
  (funcall
   (compile
    nil
    '(lambda ()
104
105
106
107
108
109
110
111
112
113
             (declare (optimize (speed 3) (debug 1)))
             (block b6
                    (flet ((%f3 ()
                                (ldb (byte 19 23)
                                     (block b1
                                            (let ()
                                                 (- (if nil (return-from b6 89627)
                                                        1160)
                                                    (return-from b1 22923)))))))
                          1)))))
114
115
116
117
118
119
120
  1)

(deftest misc.10
  (funcall
   (compile
    nil
    '(lambda (c)
121
122
123
124
125
126
127
128
129
130
131
             (declare (optimize (speed 3) (debug 1))
                      (type (integer -15417757 5816) c))
             (flet ((%f3 () (if nil -3143 c)))
                   (block b5
                          (let ((v7 (if (< 23613642 (%f3)) c -23097977)))
                               (let ((v5
                                      (return-from b5
                                                   (if (eql c v7)
                                                       (let ((v6 (%f3))) 4650813)
                                                       782))))
                                    -4362540))))))
132
133
134
135
136
137
138
139
   -10000)
  782)

(deftest misc.11
  (funcall
   (compile
    nil
    '(lambda (a b c)
140
141
142
143
144
145
146
147
148
149
             (declare (optimize (speed 3) (debug 1)))
             (block b8
                    (logxor
                     (let ((v3 (return-from b8 120789657))) 3690)
                     (block b2
                            (flet ((%f9 ()
                                        (flet ((%f10 () -1))
                                              c)))
                                  (flet ((%f3 () (let () (return-from b2 b))))
                                        a)))))))
150
151
152
153
154
155
156
157
   1 2 3)
  120789657)

(deftest misc.12
  (funcall
   (compile
    nil
    '(lambda (c)
158
159
160
161
162
163
164
             (declare (optimize (speed 3) (safety 1) (debug 1))
                      (type (integer -171067 -5) c))
             (flet ((%f16 ()
                          (flet ((%f12 () 439))
                                3358)))
                   (flet ((%f14 () c))
                         (if (%f14) -1 (%f14))))))
165
166
167
168
169
170
171
172
   -100)
  -1)

(deftest misc.13
  (funcall
   (compile
    nil
    '(lambda (b c)
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
             (declare (optimize (speed 3) (safety 1) (debug 1))
                      (type  (integer -1554410 36086789) b)
                      (type (integer -15033876209 126774299) c)
                      )
             (block b3
                    (flet ((%f9 ()
                                (abs
                                 (flet ((%f5 ()
                                             (return-from b3 -2)))
                                       (if (if (<= 1 c) b (%f5)) -65 -47895812)))))
                          (min
                           (let ((v3 (let ((v8 (%f9))) b))) b)
                           (if (= 1364001 (%f9))
                               (logeqv (block b5 -2713) -247)
                               -19))))))
188
189
190
191
192
193
194
195
   0 0)
  -2)

(deftest misc.14
  (funcall
   (compile
    nil
    '(lambda (c)
196
197
198
199
200
201
202
             (declare (notinline logandc1))
             (block b6
                    (flet ((%f17 () (return-from b6 c)))
                          (logandc1 (%f17)
                                    (if 1
                                        450967818
                                        (let ((v1 (%f17))) -17)))))))
203
204
205
206
207
208
209
210
   10)
  10)

(deftest misc.15
  (funcall
   (compile
    nil
    '(lambda (a b)
211
212
213
214
215
216
217
             (declare (optimize (speed 3) (safety 1) (debug 1)))
             (flet ((%f6 () a))
                   (block b5
                          (flet ((%f14 ()
                                       (min 17593 (block b1 (return-from b1 b)))))
                                (block b7 (if (%f6) (return-from b7 28182012)
                                              (return-from b5 0))))))))
218
219
220
221
222
223
224
225
   3 5)
  28182012)

(deftest misc.16
  (funcall
   (compile
    nil
    '(lambda (a c)
226
227
228
229
230
231
232
233
             (flet ((%f14 ()
                          (block b6
                                 (flet ((%f7 () (return-from b6 4)))
                                       (if 587793 (if (%f7) c -23086423) (%f7))))))
                   (block b1
                          (flet ((%f18 () a))
                                (logandc1 (return-from b1 -2781)
                                          (if (%f14) 58647578 -396746)))))))
234
235
236
237
238
239
240
241
   1 2)
  -2781)

(deftest misc.17
  (funcall
   (compile
    nil
    '(lambda (a b c)
242
243
244
245
246
247
248
249
250
             (declare (optimize (speed 3) (safety 1) (debug 1))
                      (type (integer 4 23363) b)
                      (type (integer -32681 41648) c)
                      )
             (flet ((%f18 ()
                          (if nil c b)))
                   (if (if (> -71810514 a) 102077 465393)
                       (block b3 (if (%f18) (return-from b3 c) c))
                       (%f18)))))
251
252
253
254
255
256
257
258
   0 10 1000)
  1000)

(deftest misc.18
  (funcall
   (compile
    nil
    '(lambda (a b c)
259
260
261
262
263
264
265
             (declare (optimize (speed 3) (safety 1) (debug 1))
                      (type (integer 7 58010860) a)
                      (type (integer -3573280 -1) b)
                      (type (integer -920848 -819) c)
                      )
             (flet ((%f15 () (if (logbitp 5 a) a c)))
                   (min (if (%f15) b -39) (if (> 0 -14756) b (%f15))))))
266
267
268
269
270
271
272
273
   8 -1000 -10000)
  -1000)

(deftest misc.19
  (funcall
   (compile
    nil
    '(lambda (a b c)
274
275
276
277
278
279
280
281
             (declare (type (integer 54 3862515) a) (type (integer -961325 1539) b)
                      (type (integer 6 31455) c) (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (lognor
              (flet ((%f13 () b)) (%f13))
              (flet ((%f1 () (return-from %f1 a)))
                    (labels ((%f3 () (%f1)))
                            -428)))))
282
283
284
285
286
287
288
289
   100 0 200)
  427)

(deftest misc.20
  (funcall
   (compile
    nil
    '(lambda (a b c)
290
291
292
293
294
295
296
297
298
             (declare (type (integer -1 31880308) a)
                      (type (integer -11374222037 5331202966) b)
                      (type (integer -483 -1) c)
                      (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (labels ((%f6 () a))
                     (if (eql (let ((v9 (%f6))) -50072824) c)
                      28146341
                      (if (< 119937 21304962) 21304962 (%f6))))))
299
300
301
302
303
304
305
306
   0 0 -1)
  21304962)

(deftest misc.21
  (funcall
   (compile
    nil
    '(lambda (a b c)
307
308
309
310
311
312
313
314
315
316
317
318
             (declare (type (integer 398 3955) a) (type (integer 233 464963) b)
                      (type (integer -124477 16) c) (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (logior
              (flet ((%f18 ()
                           -3584768))
                    (%f18))
              (flet ((%f1 ()
                          (return-from %f1 c)))
                    (flet ((%f9 ()
                                (if (%f1) 24181 7)))
                          56048)))))
319
320
321
322
323
324
325
326
   400 300 0)
  -3547152)

(deftest misc.22
  (funcall
   (compile
    nil
    '(lambda (a b c)
327
328
329
330
331
332
333
334
335
336
337
338
339
             (declare (type (integer -126378 -103) a)
                      (type (integer -1158604975 1) b)
                      (type (integer 502 28036) c)
                      (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (labels ((%f13 () c))
                     (labels ((%f3 ()
                                   (logandc1
                                    c
                                    (block b6
                                           (max -73100
                                                (if b (return-from b6 4935) (%f13)))))))
                             (%f13)))))
340
341
342
343
344
345
346
347
   -200 0 1000)
  1000)

(deftest misc.23
  (funcall
   (compile
    nil
    '(lambda (a b c)
348
349
350
351
352
353
354
355
356
357
358
359
360
             (declare (type (integer 1 18911480) a)
                      (type (integer -1 48333) b)
                      (type (integer -3881001767 -1937357) c)
                      (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (labels ((%f10 () c))
                     (block b7
                            (logorc2
                             (* (%f10)
                                (if (ldb-test (byte 27 1) -11337)
                                    (return-from b7 -2)
                                    246137101))
                             (min (%f10) (return-from b7 -76114)))))))
361
362
363
364
365
366
367
368
   1 0 -2000000)
  -2)

(deftest misc.24
  (funcall
   (compile
    nil
    '(lambda (a b c)
369
370
371
372
373
374
375
376
377
378
379
380
             (declare (type (integer -1477249397 -10697252) a)
                      (type (integer -7 54591) b)
                      (type (integer -102559556 15) c)
                      (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (block b8
                    (let ((v1 (return-from b8 a)))
                         (1+
                          (block b3
                                 (flet ((%f10 ()
                                              (min a (return-from b3 -1))))
                                       16776220)))))))
381
382
383
384
385
386
387
388
   -11000000 0 0)
  -11000000)

(deftest misc.25
  (funcall
   (compile
    nil
    '(lambda (a b c)
389
390
391
392
393
394
395
396
397
398
             (declare (type (integer -944 111244) a)
                      (type (integer 100512 3286178) b)
                      (type (integer -2170236 -107) c)
                      (ignorable a b c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (labels ((%f17 () c))
                     (labels ((%f16 () a))
                             (if (if (logbitp 10 1029643) t 355)
                                 (if (equal (%f17) b) c a)
                                 (if (= 1325844 (%f16)) -50285 (1- (%f17))))))))
399
400
401
402
403
404
405
406
   0 200000 -200)
  0)

(deftest misc.26
  (funcall
   (compile
    nil
    '(lambda (c)
407
408
409
410
411
412
413
             (declare (optimize speed))
             (block b5
                    (if (logbitp 6 -97)
                        (let ((v2 (block b8 -42484))) c)
                        (flet ((%f10 () (return-from b5 -785143)))
                              (let ((v3 (%f10)))
                                   (%f10)))))))
414
415
416
417
418
419
420
421
   0)
  -785143)

(deftest misc.27
  (funcall
   (compile
    nil
    '(lambda (a b c)
422
423
424
425
426
427
428
             (declare (optimize (speed 3) (debug 1)))
             (labels ((%f14 () c))
                     (logand (%f14)
                             (labels ((%f15 () (logeqv (let ((v1 b)) c)
                                                       (return-from %f15 -1740))))
                                     (labels ((%f8 () (%f15)))
                                             a))))))
429
430
431
432
433
434
435
436
   5 2 3)
  1)

(deftest misc.28
  (funcall
   (compile
    nil
    '(lambda (a b c)
437
438
439
440
          (declare
           (type (integer 1948 12024) b)
           (type (integer -104357939 -252) c)
           (optimize (speed 3) (debug 1)))
441
442
443
    (flet ((%f18 () c))
      (logandc1 (if (eql b (%f18)) 0 a)
                (if (ldb-test (byte 30 30) 1) (%f18) 1)
444
                ))))
445
446
447
448
449
450
451
452
   0 2000 -300)
  1)

(deftest misc.29
  (funcall
   (compile
    nil
    '(lambda (a b c)
453
454
455
456
457
458
459
460
461
462
463
464
465
466
             (declare (type (integer 661607 10451683348) a)
                      (type (integer -2 -2) b)
                      (type (integer 5996117 18803237) c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (labels ((%f16 () -29))
               (flet ((%f7 ()
                           (labels ((%f1 () a))
                             (let ()
                               (block b3
                                 (if 37101207
                                     (return-from b3 -5322045)
                                   (let ((v5 b))
                                     146099574)))))))
                 (if (%f16) c c)))))
467
468
469
470
471
472
473
474
   1000000 -2 6000000)
  6000000)

(deftest misc.30
  (funcall
   (compile
    nil
    '(lambda (c)
475
476
477
478
             (declare (type (integer -253 -1) c)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (flet ((%f8 () c))
                   (if (= (%f8) 481) (%f8) 1779465))))
479
480
481
482
483
484
   -100)
  1779465)

(deftest misc.31
  (funcall
   (compile nil
485
486
487
            '(lambda () (let ((v9 (labels ((%f13 () nil)) nil)))
                             (let ((v3 (logandc2 97 3)))
                                  (* v3 (- 37391897 (logand v3 -66))))))))
488
489
490
491
492
493
494
  3589619040)

(deftest misc.32
  (funcall
   (compile
    nil
    '(lambda (a d)
495
496
497
498
499
500
501
502
             (declare (type (integer -8507 26755) a)
                      (type (integer -393314538 2084485) d)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (gcd
              (if (= 0 a) 10 (abs -1))
              (logxor -1
                      (min -7580
                           (max (logand a 31365125) d))))))
503
504
505
506
507
508
509
510
   1 1)
  1)

(deftest misc.33
  (funcall
   (compile
    nil
    '(lambda (a b c d)
511
512
513
514
515
516
517
518
519
520
521
             (declare (type (integer 240 100434465) a)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (logxor
              (if (ldb-test (byte 27 4) d)
                  -1
                  (max 55546856 -431))
              (logorc2
               (if (>= 0 b)
                   (if (> b c) (logandc2 c d) (if (> d 224002) 0 d))
                   (signum (logior c b)))
               (logior a -1)))))
522
523
524
525
526
527
   256 0 0 0)
  55546856)

(deftest misc.34
  (funcall
   (compile nil
528
529
530
531
532
533
534
535
            `(lambda (b c)
                     (declare (type (integer -23228343 2) b)
                              (type (integer -115581022 512244512) c)
                              (optimize (speed 3) (safety 1) (debug 1)))
                     (* (* (logorc2 3 (deposit-field 4667947 (byte 14 26) b))
                           (deposit-field b (byte 25 27) -30424886))
                        (dpb b (byte 23 29) c)
                        )))
536
537
538
539
540
541
542
543
   0 0)
  0)

(deftest misc.35
  (funcall
   (compile
    nil
    '(lambda (c)
544
545
546
547
548
549
550
             (declare (type (integer -5945502333 12668542) c)
                      (optimize (speed 3)))
             (let ((v2 (* c 12)))
                  (- (max (if (/= 109335113 v2) -26479 v2)
                          (deposit-field 311
                                         (byte 14 28)
                                         (min (max 521326 c) -51)))))))
551
552
553
554
555
556
   12668542)
  26479)

(deftest misc.36
  (funcall
   (compile nil
557
558
559
560
561
562
563
564
565
566
            '(lambda ()
               (declare (notinline + logand)
                        (optimize (speed 0)))
               (logand
                (block b5
                       (flet ((%f1 ()
                                   (return-from b5 -220)))
                             (let ((v7 (%f1)))
                                  (+ 359749 35728422))))
                -24076))))
567
568
569
570
571
572
573
574
575
  -24284)

(deftest misc.37
  (funcall
   (compile
    nil
    '(lambda (b)
       (declare (notinline -) (optimize (speed 0)))
       (- (block b4
576
577
578
                 (flet ((%f4 ()
                             (return-from b4 b)))
                       (%f4))))))
579
580
581
582
583
584
585
586
   10)
  -10)

(deftest misc.38
  (funcall
   (compile
    nil
    '(lambda (x) (declare (type (integer 0 100) x)
587
                          (optimize (speed 3) (safety 1)))
588
589
590
591
592
593
594
595
596
       (logandc1 x x)))
   79)
  0)

(deftest misc.39
  (funcall
   (compile
    nil
    '(lambda (x) (declare (type (integer 0 100) x)
597
                          (optimize (speed 3) (safety 1)))
598
599
600
601
602
603
604
605
606
       (logandc2 x x)))
   79)
  0)

(deftest misc.40
  (funcall
   (compile
    nil
    '(lambda (x) (declare (type (integer 0 100) x)
607
                          (optimize (speed 3) (safety 1)))
608
609
610
611
612
613
614
615
616
       (logorc1 x x)))
   79)
  -1)

(deftest misc.41
  (funcall
   (compile
    nil
    '(lambda (x) (declare (type (integer 0 100) x)
617
                          (optimize (speed 3) (safety 1)))
618
619
620
621
622
623
624
625
626
       (logorc2 x x)))
   79)
  -1)

(deftest misc.42
  (funcall
   (compile
    nil
    '(lambda (x)
627
       (declare (type (integer -100 100) x))
628
629
630
631
632
633
       (ldb (byte 1 32) x)))
   -1)
  1)

(deftest misc.43
  (funcall (compile nil
634
635
        '(lambda () (flet ((%f2 () 288213285))
                      (+ (%f2) (* 13 (%f2)))))))
636
637
638
639
640
641
642
643
  4034985990)
  

(deftest misc.44
  (funcall
   (compile
    nil
    '(lambda (a)
644
645
646
             (declare (type (integer -917858 964754309) a)
                      (optimize (speed 3)))
             (* 25 (min (max a 171625820) 171626138))))
647
648
649
650
651
652
653
654
   861929141)
  4290653450)

(deftest misc.45
  (funcall
   (compile
    nil
    '(lambda (b)
655
656
657
             (declare (type (integer 21 9673) b)
                      (optimize (speed 3)))
             (* (integer-length -198435631) (+ b 137206182))))
658
659
660
661
662
663
664
   6027)
  3841941852)

(deftest misc.46
  (funcall
   (compile
    nil
665
    '(lambda (b c)
666
667
668
669
670
             (declare (type (integer 0 1) b) (optimize (speed 3)))
             (flet ((%f2 () (lognor (block b5 138) c)))
                   (if (not (or (= -67399 b) b))
                       (deposit-field (%f2) (byte 11 8) -3)
                       c))))
671
672
673
   0 0)
  0)

674
675
676
677
678
(deftest misc.47
  (funcall
   (compile
    nil
    '(lambda (a)
679
680
681
             (declare (type (integer -4005718822 -50081775) a)
                      (optimize (speed 3) (safety 1) (debug 1)))
             (lognor (ash a (min 0 a)) a)))
682
683
684
685
686
687
688
689
690
691
692
693
694
   -2878148992)
  0)

(deftest misc.48
  (funcall
   (compile
    nil
    '(lambda (a) (declare (notinline ash min)) (lognor (ash a (min 0 a)) a)))
   -2878148992)
  0)

(deftest misc.49
  (let ((body '(truncate (logorc1 -996082 C) -2))
695
        (arg 25337234))
696
697
698
    (values
     (funcall (compile nil `(lambda (c) ,body)) arg)
     (funcall (compile nil `(lambda (c) (declare (notinline truncate))
699
                              ,body)) arg)))
700
701
702
703
704
  -13099001
  -13099001)

(deftest misc.50
  (funcall (compile nil `(lambda (c)
705
706
707
708
                           (declare (optimize (speed 3))
                                    (type (integer 23062188 149459656) c))
                           (mod c (min -2 0))))
           95019853)
709
710
711
712
  -1)

(deftest misc.51
  (funcall (compile nil `(lambda (b)
713
714
715
716
                           (declare (optimize (speed 3))
                                    (type (integer 2 152044363) b))
                            (rem b (min -16 0))))
           108251912)
717
  8)
718
719
720
721
  
(deftest misc.53
  (funcall
   (compile nil '(lambda ()
722
723
724
725
726
727
                   (let (x)
                     (block nil
                       (flet ((%f (y z) (if (> y z) (setq x y) (setq x z))))
                         (%f 1 2)
                         (%f (return 14) 2)))
                     x))))
728
729
730
731
732
  2)

(deftest misc.54
  (funcall
   (compile nil '(lambda (a c)
733
734
735
736
737
738
                   (declare (type (integer 8 117873977) a)
                            (type (integer -131828754 234037511) c)
                            (optimize (speed 3) (safety 1) (debug 1)))
                   (* (mod (signum a) (max 50 -358301))
                      (* -2320445737132
                         (* (* a (deposit-field a (byte 32 19) a)) c)))))
739
740
741
742
743
744
   11386 165297671)
  -49725654774521915007942373712)

(deftest misc.55
  (funcall
   (compile nil '(lambda (a b c)
745
746
747
748
749
750
751
752
753
754
755
                   (declare (type (integer -5498929 389890) a)
                            (type (integer -5029571274946 48793670) b)
                            (type (integer 9221496 260169518304) c)
                            (ignorable a b c)
                            (optimize (speed 3) (safety 1) (debug 1)))
                   (- (mod 1020122 (min -49 -420))
                      (logandc1
                       (block b2
                         (mod c (min -49 (if t (return-from b2 1582) b))))
                       (labels ((%f14 () (mod a (max 76 8))))
                         b)))))
756
757
758
759
760
761
   -1893077 -2965238893954 30902744890)
  2965238894454)

(deftest misc.56
  (funcall
   (compile nil '(lambda (a c)
762
763
764
765
                   (declare (type (integer -8691408487404 -9) a)
                            (type (integer 266003133 2112105962) c)
                            (optimize (speed 3) (safety 1) (debug 1)))
                   (truncate (max (round a) c) (* (* a a) a))))
pfdietz's avatar
pfdietz committed
766
767
768
   -10 266003133)
  -266003
  133)
pfdietz's avatar
pfdietz committed
769
770
771
772
773
774
775
776
777
778
779
780
781

(deftest misc.57
  (funcall
   (compile nil '(lambda (a b c)
                         (declare (type (integer -1907 58388940297) a)
                                  (type (integer -646968358 294016) b)
                                  (type (integer -708435313 89383896) c)
                                  (optimize (speed 3) (safety 1) (debug 1)))
                         (let ((v6 (abs (min a (signum c)))))
                              (if (ceiling v6 (max 77 v6)) b 2))))
   50005747335 -363030456 17382819)
  -363030456)

pfdietz's avatar
pfdietz committed
782
783
784
(deftest misc.58
  (funcall
   (compile nil '(lambda (a)
785
786
787
                   (declare (type (integer -23 66141285) a)
                            (optimize (speed 3)))
                   (logorc2 (setq a 35191330) (* a 107))))
pfdietz's avatar
pfdietz committed
788
789
790
791
792
   4099241)
  -3764388885)

(deftest misc.59
  (funcall
793
   (compile nil '(lambda (a b c)
794
795
796
797
798
799
                   (declare (type (integer -3966039360 -879349) a)
                            (type (integer -62642199164 -8993827395) b)
                            (type (integer -8065934654337 223) c)
                            (optimize (speed 3) (safety 1) (debug 1)))
                   (floor (* (ceiling c) c)
                          (max 78 (* b (* a (* a b)))))))
pfdietz's avatar
pfdietz committed
800
801
802
   -1000000 -10000000000 0)
  0 0)

803
804
805
(deftest misc.60
  (funcall
    (compile nil
806
807
808
             '(lambda ()
                (let ((v5 46660))
                  (setq v5 (signum (rem v5 (max 53 v5))))))))
809
810
811
812
813
  0)

(deftest misc.61
  (progn
    (compile nil
814
815
816
817
818
819
             '(lambda (a b)
                (declare (type (integer -1785799651 -2) a)
                         (type (integer -27 614132331) b)
                         (optimize (speed 3) (safety 1) (debug 1)))
                (ceiling (max (floor -733432 (max 84 -20)) 346)
                         (min -10 (* 17592186028032 (* (* a b) a))))))
820
821
822
823
824
    :good)
  :good)

(deftest misc.62
  (funcall (compile nil '(lambda (a)
825
826
827
828
                (if (and (if a t nil) nil)
                    a
                  (min (block b5 -1) a))))
           100)
829
830
  -1)

831
;;; sbcl bug (probably #233)
832
833
(deftest misc.63
  (let* ((form '(flet ((%f12 () (setq c -9868204937)))
834
835
836
837
838
839
                  (if (<= c (%f12)) -2 (if (= c c) b c))))
         (form1 `(lambda (b c)
                   (declare (type (integer -80421740610 1395590616) c))
                   ,form))
         (form2 `(lambda (b c) ,form))
         (vals '(-696742851945 686256271)))
840
    (eqlt (apply (compile nil form1) vals)
841
          (apply (compile nil form2) vals)))
842
843
  t)

844
;;; sbcl bug (probably #233)
845
846
(deftest misc.64
  (let* ((form '(logcount
847
848
849
850
851
852
853
854
855
                 (if (not (> c (let ((v7 (setq c -246180))) -1)))
                     (ldb (byte 24 11) c)
                   c)))
         (form1 `(lambda (c)
                   (declare (type (integer -256128 207636) c))
                   ,form))
         (form2 `(lambda (c) ,form))
         (vals '(11292))
         )
856
    (eqlt (apply (compile nil form1) vals)
857
          (apply (compile nil form2) vals)))
858
859
  t)

860
;;; sbcl bug (probably #233)
861
862
(deftest misc.65
  (let ((form1 '(lambda (b c)
863
864
865
866
867
                  (declare (type (integer -350684427436 -255912007) b))
                  (logandc2 c (if (< b (setq b -25647585550)) b 0))))
        (form2 '(lambda (b c)
                  (logandc2 c (if (< b (setq b -25647585550)) b 0))))
        (vals '(-297090677547 -20121092)))
868
    (eqlt (apply (compile nil form1) vals)
869
          (apply (compile nil form2) vals)))
870
871
872
873
  t)

(deftest misc.66
  (let* ((form '(if (> a (setq a -2198578292))
874
875
876
877
878
879
880
881
                    (min b (if (<= a -14866) a -128363))
                  a))
         (form1 `(lambda (a b)
                   (declare (type (integer -3709231882 0) a))
                   (declare (type (integer -562051054 -1) b))
                   ,form))
         (form2 `(lambda (a b) ,form))
         (vals '(-2095414787 -256985442)))
882
    (eqlt (apply (compile nil form1) vals)
883
          (apply (compile nil form2) vals)))
884
885
  t)

886
887
888
889
;;; sbcl/cmucl bug (on sparc)
(deftest misc.67
  (funcall
    (compile nil '(lambda (x)
890
891
892
                    (declare (type (integer 10604862 10604862) x)
                             (optimize speed))
                    (* x 390)))
893
894
    10604862)
  4135896180)
895
896
897
898
899

;;; cmucl bug (cvs, 10/10/2003)
(deftest misc.68
  (funcall
   (compile nil
900
901
902
            '(lambda (b)
               (flet ((%f8 () (rem b (identity (return-from %f8 0)))))
                 (lognor (%f8) 0))))
903
904
905
906
907
908
   0)
  -1)

(deftest misc.69
  (funcall
   (compile nil
909
910
911
912
            '(lambda (b)
               (flet ((%f11 () (logorc2 (block b1 (let () (return-from b1 b)))
                                        -1984)))
                 b)))
913
914
915
916
917
918
   0)
  0)

(deftest misc.70
  (funcall
   (compile nil '(lambda (c)
919
920
                   (declare (type (integer 46156191457 126998564334) c))
                   (truncate c (min -16 186196583))))
921
922
923
924
925
926
927
   87723029763)
  -5482689360
  3)

(deftest misc.71
  (funcall
   (compile nil
928
929
930
931
932
933
934
935
            '(lambda ()
               (block b8
                 (if (identity (return-from b8 30))
                     1
                   (identity
                    (block b5
                      (labels ((%f10 () (min -52 (return-from b5 10))))
                        20))))))))
936
937
938
939
940
  30)

(deftest misc.72
  (funcall
   (compile nil '(lambda ()
941
942
                   (flet ((%f13 () (rem 1 (min 0 (return-from %f13 17)))))
                     (%f13)))))
943
944
945
946
947
  17)

(deftest misc.73
  (funcall
   (compile nil '(lambda (c)
948
949
                   (declare (type (integer 46156191457 126998564334) c))
                   (rem c (min -1 0))))
950
951
   87723029763)
  0)
952
953
954

(deftest misc.74
  (funcall (compile nil '(lambda ()
955
956
                           (declare (optimize (safety 3) (speed 0) (debug 0)))
                           (ash 6916244 (min 42 -185236061640)))))
957
  0)
958
959
960
961
962
963
964
965
966
967
968
969
970

;;; Unwind-protect bug, from sbcl:
;;; "The value NIL is not of type SB-C::NODE."

(deftest misc.75
  (funcall (compile nil '(lambda () (flet ((%f12 () (unwind-protect 1))) 0))))
  0)


;;; cmucl (2003-10-12), "NIL is not of type C::REF"
(deftest misc.76
  (funcall
   (compile nil
971
972
973
            '(lambda (a c)
                (if nil (unwind-protect (max 521739 (unwind-protect c)))
                  (logandc2 3942 a))))
974
975
976
977
978
979
980
981
982
983
984
985
986
   0 0)
  3942)

;;; gcl (2003-10-11)  Miscomputation of (mod 0 -53) in compiled code
(deftest misc.77
  (funcall (compile nil '(lambda () (mod 0 -53))))
  0)


;;; cmucl (2003-10-12)  "NIL is not of type C::BYTE-LAMBDA-INFO"
(deftest misc.78
  (funcall
   (compile nil '(lambda ()
987
988
989
990
991
992
                   (declare (optimize (speed 0) (debug 0)))
                   (let ((v4
                          (case 227
                            ((-11113 -106126) (unwind-protect 8473))
                            (t 43916))))
                     -12))))
993
994
995
996
997
998
999
  -12)

;;; Same as misc.78, but with no declarations
;;; In cmucl (2003-10-12)  "NIL is not of type C::ENVIRONMENT"
(deftest misc.79
  (funcall
   (compile nil '(lambda ()
1000
1001
1002
1003
1004
                   (let ((v4
                          (case 227
                            ((-11113 -106126) (unwind-protect 8473))
                            (t 43916))))
                     -12))))
1005
1006
  -12)

1007
1008
1009
1010
1011
1012
1013
(deftest misc.79a
  (funcall
   (compile
    nil
    '(lambda (a b)
       (declare (type (integer 72504 351460) a))
       (declare (type (integer 2383 108330) b))
1014
1015
       (declare        (optimize (speed 2) (space 0) (safety 0)
                          (debug 2) (compilation-speed 1)))
1016
       (if (or (or (/= b 0) (logbitp 0 0)) (logbitp 0 a))
1017
1018
           0
         (funcall (constantly 0) b 0 (catch 'ct4 b)))))
1019
1020
1021
1022
   132318 12238)
  0)


1023
1024
1025
1026
;;; cmucl (2003-10-12) "Invalid number of arguments: 2"
(deftest misc.80
  (funcall
   (compile nil
1027
1028
1029
1030
1031
1032
1033
1034
1035
            '(lambda (b c)
               (declare (notinline > logior imagpart))
               (declare (optimize (speed 0) (debug 0)))
               (labels ((%f16 ()
                              (imagpart
                               (block b3
                                 (logeqv (logior -122516 (if (> -1 0) (return-from b3 c) b))
                                         (return-from %f16 32186310))))))
                 (lognor (%f16) b))))
1036
1037
1038
1039
1040
1041
1042
   -123886 -1656)
  57385)

;;; cmucl (2003-10-12) "NIL is not of type C::REF"
(deftest misc.81
  (funcall
   (compile nil '(lambda (b)
1043
1044
1045
                   (block b7
                     (let ((v3 (return-from b7 b)))
                       (unwind-protect b)))))
1046
1047
1048
1049
1050
1051
1052
   17)
  17)

;;; cmucl (2003-10-12) "The assertion C::SUCC failed"
(deftest misc.82
  (funcall
   (compile nil '(lambda (c)
1053
1054
1055
1056
1057
                   (labels ((%f15 ()
                                  (* (unwind-protect c)
                                     (max -5726369
                                          (return-from %f15 3099206)))))
                     c)))
1058
1059
1060
   0)
  0)

1061
1062
1063
1064
;;; cmucl (2003-10-13) "The assertion (NOT (C::BLOCK-DELETE-P BLOCK)) failed."
(deftest misc.83
  (funcall
   (compile nil '(lambda (a c)
1065
1066
                   (flet ((%f8 () (min c (min a (return-from %f8 c)))))
                     c)))
1067
1068
1069
1070
1071
1072
   0 -10)
  -10)

(deftest misc.84
  (funcall
   (compile nil '(lambda (a b)
1073
1074
1075
1076
1077
1078
                   (flet ((%f18 ()
                                (let ()
                                  (let ()
                                    (if (ldb-test (byte 20 23) b) a
                                      (return-from %f18 431))))))
                     -674)))
1079
1080
1081
1082
1083
1084
   0 0)
  -674)

(deftest misc.85
  (funcall
   (compile nil
1085
1086
1087
1088
1089
1090
            '(lambda (c)
               (labels ((%f14 ()
                              (let ()
                                (logandc1 (min -32 (return-from %f14 -69793))
                                          c))))
                     156)))
1091
1092
   0)
  156)
1093
1094
1095
1096

;;; Two tests showing bug(s) in clisp (2.31)
(deftest misc.86
  (funcall (compile nil '(lambda (b)
1097
1098
1099
1100
                           (flet ((%f10 nil :bad))
                             (let ((v7 (let ((v2 (%f10))) b)))
                               (unwind-protect b)))))
           :good)
1101
1102
1103
1104
  :good)

(deftest misc.87
  (apply (compile nil '(lambda (a b c)
1105
1106
1107
1108
                         (let ((v9 a))
                           (let ((v2 (setq v9 c)))
                             (unwind-protect c)))))
         '(x y z))
1109
1110
  z)

1111
;;; cmucl bug (18e+ 10/15/03)
1112
1113
(deftest misc.88
  (eval '(block b3
1114
1115
           (max (return-from b3 1)
                (if (unwind-protect (unwind-protect 2)) 3 4))))
1116
  1)
1117

1118
;;;
1119
;;; cmucl bug (18e+ 10/15/03)
1120
1121
1122
1123
1124
1125
1126
;;; Also occurs in sbcl (0.8.16.20)
;;;  "Too large to be represented as a SINGLE-FLOAT"
;;; (a large bignum is coerced to a single-float in type propagation,
;;;  with unfortunate results.)
;;;

;;; Here, the function were the problem occurs is -
1127
1128
1129
(deftest misc.89
  (funcall
   (compile nil
1130
1131
1132
1133
            '(lambda (c)
               (declare (type (integer 0 130304) c))
               (- (rem -26 (max 25 (load-time-value 505849129)))
                  (* -15718867961526428520296254978781964 c))))
1134
   0)
1135
  -26)
1136

1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
;;; Here, it is MAX
(deftest misc.89a
  (funcall
   (compile
    nil
    '(lambda (a b c d)
       (declare (type (integer -265115792172 -206231862770) a))
       (declare (type (integer 11069 58322510034) b))
       (declare (type (integer -7351 28730) c))
       (declare (type (integer -913299295156 3670905260104) d))
       (declare (ignorable a b c d))
       (declare
1149
1150
        (optimize (safety 1) (space 1) (compilation-speed 2)
                  (debug 0) (speed 2)))
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
       (- (signum (catch 'ct6 0)) (numerator (* -1303 d -20527703 d c)))))
   -261283766805 41605749408 5110 1269102278886)
  -220139978315039892599545286437019126040)

;;; Here, it is MOD
(deftest misc.89b
  (funcall
   (compile
    nil
    '(lambda (a b c d)
       (declare (type (integer -481454219025 239286093202) a))
       (declare (type (integer -1121405368785 213522) b))
       (declare (type (integer -103720347879 -241) c))
       (declare (type (integer -12830115357 3027711346) d))
       (declare (ignorable a b c d))
       (declare (optimize (speed 2) (compilation-speed 1) (space 1)
1167
                          (safety 3) (debug 2)))
1168
1169
1170
1171
       (floor (load-time-value 0) (min -18 (* a c b -12626)))))
   -78545446876 -460518205737 -38885914099 1598305189)
  0 0)

pfdietz's avatar
pfdietz committed
1172
;;; acl bugs (version 6.2, linux x86 trial)
1173
1174
(deftest misc.90
  (let* ((form '(- 0 (ignore-errors 20763)
1175
1176
1177
1178
1179
1180
1181
1182
                   (logxor b 1 c -7672794) b))
         (fn1 `(lambda (b c)
                 (declare (type (integer -148895 -46982) b))
                 (declare (type (integer 0 1) c))
                 (declare (optimize (speed 3)))
                 (declare (optimize (safety 1)))
                 ,form))
         (fn2 `(lambda (b c) ,form)))
1183
    (let ((v1 (funcall (compile nil fn1) -76071 0))
1184
1185
          (v2 (funcall (compile nil fn2) -76071 0))
          (v3 (funcall (eval `(function ,fn2)) -76071 0)))
1186
      (if (= v1 v2 v3) :good
1187
        (list v1 v2 v3))))
1188
1189
1190
1191
  :good)

(deftest misc.91
  (let ((fn1 '(lambda ()
1192
1193
1194
                (declare (optimize (speed 3) (safety 1)))
                (ash -10 (min 8 -481))))
        (fn2 '(lambda () (ash -10 (min 8 -481)))))
1195
    (let ((v1 (funcall (compile nil fn1)))
1196
1197
          (v2 (funcall (compile nil fn2)))
          (v3 (funcall (eval `(function ,fn2)))))
1198
      (if (= v1 v2 v3)
1199
1200
          :good
        (list v1 v2 v3))))
1201
1202
1203
1204
  :good)

(deftest misc.92
  (let* ((form '(- -16179207 b (lognor (let () 3) (logxor -17567197 c))))
1205
1206
1207
1208
1209
1210
1211
         (fn1 `(lambda (b c)
                 (declare (type (integer -621 30) c))
                 (declare (optimize (speed 3)))
                 (declare (optimize (safety 1)))
                 ,form))
         (fn2 `(lambda (b c) ,form))
         (vals '(26291532469 -21)))
1212
    (let ((v1 (apply (compile nil fn1) vals))
1213
1214
          (v2 (apply (compile nil fn2) vals))
          (v3 (apply (eval `(function ,fn2)) vals)))
1215
      (if (= v1 v2 v3)
1216
1217
          :good
        (list v1 v2 v3))))
1218
1219
  :good)

pfdietz's avatar
pfdietz committed
1220
1221
(deftest misc.93
  (let* ((form '(ash (1+ (flet ((%f5 (f5-1) c)) c))
1222
1223
1224
1225
1226
1227
1228
1229
                     (min 69 (logxor a b))))
         (fn1 `(lambda (a b c)
                 (declare (type (integer -128 -109) a)
                          (type (integer -2 -1) b)
                          (optimize (speed 3) (safety 1)))
                 ,form))
         (fn2 `(lambda (a b c) ,form))
         (vals '(-123 -1 2590941967601)))
pfdietz's avatar
pfdietz committed
1230
    (eqlt (apply (compile nil fn1) vals)
1231
          (apply (compile nil fn2) vals)))
pfdietz's avatar
pfdietz committed
1232
1233
1234
1235
  t)

(deftest misc.94
  (not (funcall
1236
1237
1238
1239
1240
        (compile nil '(lambda ()
                        (declare (optimize (speed 3) (safety 1) (debug 1)))
                        (<= 268435280
                            (load-time-value
                             39763134374436777607194165739302560271120000))))))
pfdietz's avatar
pfdietz committed
1241
1242
1243
1244
  nil)

(deftest misc.95
  (let* ((form '(+ 272 c (if (< b a) -49618 -29042) b))
1245
1246
1247
1248
1249
1250
1251
1252
         (fn1 `(lambda (a b c)
                 (declare (type (integer -1585918 601848636) a))
                 (declare (type (integer -4 16544323) b))
                 (declare (optimize (speed 3)))
                 (declare (optimize (safety 1)))
                 ,form))
         (fn2 `(lambda (a b c) ,form))
         (vals '(601739317 10891850 17452477960)))
pfdietz's avatar
pfdietz committed
1253
    (let ((v1 (apply (compile nil fn1) vals))
1254
          (v2 (apply (compile nil fn2) vals)))
pfdietz's avatar
pfdietz committed
1255
      (if (eql v1 v2)
1256
1257
          :good
        (list v1 v2))))
pfdietz's avatar
pfdietz committed
1258
1259
1260
1261
  :good)

(deftest misc.96
  (let* ((form '(max 26 (ceiling b (min -8 (max -1 c)))))
1262
1263
1264
1265
1266
1267
1268
1269
         (fn1 `(lambda (b c)
                 (declare (type (integer 482134 96074347505) b))
                 (declare (type (integer -4036 -50) c))
                 (declare (optimize (speed 3)))
                 (declare (optimize (safety 1)))
                 ,form))
         (fn2 `(lambda (b c) ,form))
         (vals '(90244278480 -338)))
pfdietz's avatar
pfdietz committed
1270
    (let ((v1 (apply (compile nil fn1) vals))
1271
          (v2 (apply (compile nil fn2) vals)))
pfdietz's avatar
pfdietz committed
1272
      (if (eql v1 v2)
1273
1274
          :good
        (list v1 v2))))
pfdietz's avatar
pfdietz committed
1275
1276
1277
1278
  :good)

(deftest misc.97
  (let* ((form '(- 349708 (gcd c 0) (logand b b (if (> -8543459 c) 83328 1073))))
1279
1280
1281
1282
1283
1284
1285
1286
         (fn1 `(lambda (b c)
                 (declare (type (integer 301653 329907) b))
                 (declare (type (integer 171971491 1073721279) c))
                 (declare (optimize (speed 3)))
                 (declare (optimize (safety 1)))
                 ,form))
         (fn2 `(lambda (b c) ,form))
         (vals '(321769 1073671227)))
pfdietz's avatar
pfdietz committed
1287
    (let ((v1 (apply (compile nil fn1) vals))
1288
          (v2 (apply (compile nil fn2) vals)))
pfdietz's avatar
pfdietz committed
1289
      (if (eql v1 v2)
1290
1291
          :good
        (list v1 v2))))
pfdietz's avatar
pfdietz committed
1292
1293
  :good)

1294
1295
1296
1297
;;; sbcl bugs (0.8.4.40, x86 linux)

(deftest misc.98
  (funcall (compile nil '(lambda (x)
1298
1299
1300
                           (declare (type (integer -1000000 1000000) x))
                           (logand x x 0)))
           12345)
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
  0)

(deftest misc.99
  (funcall
   (compile nil '(lambda (a)
                   (declare (type (integer 4303063 101130078) a))
                   (mask-field (byte 18 2) (ash a 77))))
   57132532)
  0)

(deftest misc.100
  (funcall (compile nil '(lambda (c)
1313
1314
1315
1316
1317
1318
                           (declare (type (integer -3924 1001809828) c))
                           (declare (optimize (speed 3)))
                           (min 47 (if (ldb-test (byte 2 14) c)
                                       -570344431
                                     (ignore-errors -732893970)))))
           705347625)
1319
1320
1321
1322
1323
  -570344431)

(deftest misc.101
  (funcall
   (compile nil '(lambda (a c)
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
                   (declare (type (integer 185501219873 303014665162) a))
                   (declare (type (integer -160758 255724) c))
                   (declare (optimize (speed 3)))
                   (let ((v8
                          (- -554046873252388011622614991634432
                             (ignore-errors c)
                             (unwind-protect 2791485))))
                     (max (ignore-errors a)
                          (let ((v6 (- v8 (restart-case 980))))
                            (min v8 v6))))))
1334
1335
   259448422916 173715)
  259448422916)
pfdietz's avatar
pfdietz committed
1336

1337
1338
1339
(deftest misc.102
  (funcall
   (compile nil '(lambda (b)
1340
1341
1342
                   (declare (type (integer -1598566306 2941) b))
                   (declare (optimize (speed 3)))
                   (max -148949 (ignore-errors b))))
1343
1344
1345
1346
1347
1348
   0)
  0)

(deftest misc.103
  (funcall
   (compile nil '(lambda (a b)
1349
1350
1351
1352
1353
1354
1355
1356
1357
                   (min -80
                        (abs
                         (ignore-errors
                           (+
                            (logeqv b
                                    (block b6
                                      (return-from b6
                                        (load-time-value -6876935))))
                            (if (logbitp 1 a) b (setq a -1522022182249))))))))
1358
1359
   -1802767029877 -12374959963)
  -80)
pfdietz's avatar
pfdietz committed
1360

1361
1362
1363
(deftest misc.104
  (funcall
   (compile nil '(lambda (a) (declare (type (integer 55400028 60748067) a))
1364
                   (lognand 1505 (ash a (let () 40)))))
1365
1366
   58194485)
  -1)
pfdietz's avatar
pfdietz committed
1367

1368
1369
1370
(deftest misc.105
  (funcall
   (compile nil '(lambda (b c)
1371
1372
1373
1374
1375
1376
1377
1378
1379
                   (declare (type (integer -4 -3) c))
                   (block b7
                     (flet ((%f1 (f1-1 f1-2 f1-3)
                                 (if (logbitp 0 (return-from b7
                                                  (- -815145138 f1-2)))
                                     (return-from b7 -2611670)
                                   99345)))
                       (let ((v2 (%f1 -2464 (%f1 -1146 c c) -2)))
                         b)))))
1380
1381
   2950453607 -4)
  -815145134)
pfdietz's avatar
pfdietz committed
1382
1383
1384
1385
1386
1387

;;; Gives the error The value NIL is not of type INTEGER.  (in sbcl 0.8.4.40)

(deftest misc.106
  (progn
    (eval '(defun misc.106-fn (a b c)
1388
1389
1390
1391
             (declare (optimize speed))
             (block b6
               (flet ((%f8 (f8-1 f8-2) b))
                 (%f8 (%f8 c 338) (if t (return-from b6 a) c))))))
pfdietz's avatar
pfdietz committed
1392
1393
1394
    (misc.106-fn -30271 -1 -3043))
  -30271)

pfdietz's avatar
pfdietz committed
1395
1396
1397
1398
 ;;; "The value NIL is not of type SB-C::IR2-LVAR." (sbcl 0.8.4.40)
(deftest misc.107
  (funcall
   (compile nil
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
            '(lambda (b c)
               (declare (type (integer -29742055786 23602182204) b))
               (declare (type (integer -7409 -2075) c))
               (declare (optimize (speed 3)))
               (floor
                (labels ((%f2 ()
                              (block b6
                                (ignore-errors (return-from b6
                                                 (if (= c 8) b 82674))))))
                  (%f2)))))
pfdietz's avatar
pfdietz committed
1409
   22992834060 -5833)
pfdietz's avatar
pfdietz committed
1410
  82674 0)
pfdietz's avatar
pfdietz committed
1411

1412
1413
1414
1415
1416
;;; "The value NIL is not of type SB-C::IR2-LVAR." (sbcl 0.8.10.15)
(deftest misc.107a
  (funcall
   (compile
    nil
pfdietz's avatar
pfdietz committed
1417
    '(lambda ()
1418
       (declare
1419
1420
        (optimize (speed 2) (space 0) (safety 1)
                  (debug 3) (compilation-speed 0)))
1421
       (flet ((%f14
1422
1423
1424
1425
1426
               (f14-1
                &optional (f14-2 (rationalize (catch 'ct4 0))) (f14-3 0)
                (f14-4 0))
               (dotimes (iv2 0 0) (progn f14-2))))
         (apply #'%f14 0 0 0 nil)))))
1427
1428
  0)

1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
;;; "The value NIL is not of type SB-C::IR2-LVAR." (sbcl 0.8.14.18)

(deftest misc.107b
  (funcall
   (compile
    nil
    '(lambda (a b c)
       (declare (type (integer 7215 1030625885) a))
       (declare (type (integer -4361 -6) b))
       (declare (type (integer -3798210806 -898) c))
       (declare (ignorable a b c))
       (declare
1441
1442
1443
1444
1445
        (optimize (speed 2)
                  (space 2)
                  (safety 2)
                  (debug 3)
                  (compilation-speed 1)))
1446
       (block b4
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
         (let ((*s7* (cons c 0)))
           (declare (special *s7*))
           (return-from b4
             (prog1 0
               (the integer
                 (integer-length
                  (1+
                   (let ()
                     (gcd (cdr *s7*)
                          (case b
                            ((31 38 20 0 5 45) 2)
                            ((34 35 64 61 47) 39)
                            ((58) a)
                            (t 131788)))))))))))))
1461
1462
1463
1464
1465
1466
1467
1468
1469
   734649164 -3343 -2306504518)
  0)

(deftest misc.107c
  (funcall
   (compile
    nil
    '(lambda (c)
       (declare (optimize (speed 2) (space 1) (safety 1) (debug 3)
1470
                          (compilation-speed 0)))
1471
       (let* ((*s6*
1472
1473
1474
               (unwind-protect 0 (the integer (ash 2914825 (min 8 c))))))
         (declare (special *s6*))
         0)))
1475
1476
1477
1478
1479
1480
1481
   -105)
  0)

(deftest misc.107d
  (funcall
   (compile
    nil
1482
    '(lambda (a b)
1483
       (declare (optimize (speed 1) (space 1) (safety 1) (debug 3)
1484
                          (compilation-speed 1)))
1485
       (catch 'ct4
1486
1487
1488
1489
1490
1491
1492
         (logorc1
          (the integer
            (case (dotimes (iv2 2 2) (progn 203))
              ((-51) -59598)
              ((-31 -150) a)
              (t b)))
          (throw 'ct4 0)))))
1493
   10 20)
1494
1495
1496
1497
1498
1499
1500
1501
  0)

(deftest misc.107e
  (funcall
   (compile
    nil
    '(lambda (a)
       (declare (optimize (speed 1) (space 0) (safety 1)
1502
                          (debug 3) (compilation-speed 1)))
1503
       (flet ((%f11 (&key (key1 (the integer (- a 245241933)))) 0))
1504
         (%f11))))
1505
1506
1507
   1)
  0)

pfdietz's avatar
pfdietz committed
1508
1509
1510
1511
1512
;;; cmucl bug (Argument X is not a NUMBER: NIL)

(deftest misc.108
  (funcall
   (compile nil '(lambda (b)
1513
                   (block b7 (- b (ignore-errors (return-from b7 57876))))))
pfdietz's avatar
pfdietz committed
1514
1515
   10)
  57876)
1516
1517
1518
1519

;;; "The assertion (C::CONSTANT-CONTINUATION-P C::CONT) failed." (cmucl)
(deftest misc.109
  (funcall (compile
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
            nil
            '(lambda ()
               (load-time-value
                (block b4
                  (* (return-from b4 -27)
                     (block b5
                       (return-from b4
                         (return-from b5
                           (ignore-errors (unwind-protect
                                              (return-from b5 0))))))))))))
1530
1531
1532
  -27)

;;; This bug was occuring a lot in sbcl, and now occurs in cmucl too
pfdietz's avatar
pfdietz committed
1533
;;; NIL fell through ETYPECASE expression.  Wanted one of (C:FIXUP X86::EA C:TN).
1534
1535
1536
(deftest misc.110
  (funcall
   (compile nil
1537
1538
1539
1540
            '(lambda (c)
               (declare (type (integer -1441970837 -427) c))
               (declare (optimize (speed 3)))
               (block b7 (abs (min c (ignore-errors (return-from b7 c)))))))
1541
1542
1543
   -500)
  -500)

1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
;;; In sbcl 0.8.10.14
;;;  NIL fell through ETYPECASE expression.
;;;  Wanted one of (SB-C:FIXUP SB-VM::EA SB-C:TN).

(deftest misc.110a
  (funcall
   (compile
    nil
    '(lambda (a b c d e f)
       (declare (type (integer -1294746569 1640996137) a))
       (declare (type (integer 33628514900 90005963619) b))
       (declare (type (integer -807801310 3) c))
       (declare (type (integer 36607 121946) d))
       (declare (type (integer -6669690514043 -1776180885905) e))
       (declare (type (integer -1472 1979) f))
       (declare (ignorable a b c d e f))
       (declare
1561
1562
1563
1564
1565
        (optimize (speed 3)
                  (space 3)
                  (safety 0)
                  (debug 0)
                  (compilation-speed 3)))
1566
       (catch 'ct7
1567
1568
1569
1570
1571
1572
1573
1574
1575
         (if
             (logbitp 0
                      (if (/= 0 a)
                          c
                        (ignore-errors
                          (progn
                            (if
                                (ldb-test (byte 0 0) (rational (throw 'ct7 0)))
                                0
1576
                              0)
1577
1578
1579
                            0))))
             0
           0))))
1580
1581
1582
   391833530 36648101240 -32785211 91893 -4124561581760 1358)
  0)

1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
;;; CLISP (2.31+) compiler bug

(deftest misc.111
  (funcall
   (compile nil
            '(lambda (a c)
               (if (or (ldb-test (byte 12 18) a)
                       (not (and t (not (if (not (and c t)) nil nil)))))
                   170 -110730)))
   3035465333 1919088834)
  170)
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607

;;; sbcl (0.8.5.8) "The value NIL is not of type SB-C::IR2-LVAR."

(deftest misc.112
  (funcall
   (compile nil '(lambda (a)
                   (declare (type (integer -944 -472) a))
                   (declare (optimize (speed 3)))
                   (round
                    (block b3
                      (return-from b3
                        (if (= 55957 a) -117 (ignore-errors
                                               (return-from b3 a))))))))
   -589)
1608
  -589 0)
1609
1610
1611
1612
1613
1614

;;; sbcl (0.8.5.8) "The value NIL is not of type SB-C::CTRAN"

(deftest misc.113
  (funcall
   (compile nil '(lambda (b c)
1615
1616
1617
1618
1619
1620
                   (if (or (ldb-test (byte 8 10) b) t)
                       c
                     (min (if (<= -6467 c) c 6)
                          (flet ((%f3 (f3-1 f3-2)
                                      f3-1))
                            (multiple-value-call #'%f3 (values b 107)))))))
1621
1622
1623
   -238 -23658556)
  -23658556)

pfdietz's avatar
pfdietz committed
1624
1625
1626
1627
1628
;;; clisp (1 Oct 2003 cvs HEAD)  "*** - CAR: #:G7744659 is not a LIST"

(deftest misc.114
  (funcall
   (compile nil
1629
            '(lambda (a b)
pfdietz's avatar
pfdietz committed
1630
1631
1632
               (unwind-protect
                   (block b2
                     (flet ((%f1 nil b))
1633
                       (logior (if a
1634
1635
1636
1637
                                   (if (ldb-test (byte 23 1) 253966182)
                                       (return-from b2 a)
                                     -103275090)
                                 62410)
pfdietz's avatar
pfdietz committed
1638
1639
                               (if (not (not (if (not nil) t (ldb-test (byte 2 27) 253671809))))
                                   (return-from b2 -22)
1640
1641
                                 (%f1))))))))
   777595384624 -1510893868)
pfdietz's avatar
pfdietz committed
1642
1643
  777595384624)

1644
1645
1646
1647
1648
1649
;;; clisp (1 Oct 2003 cvs HEAD) "Compiler bug!! Occurred in OPTIMIZE-LABEL."

(deftest misc.115
  (funcall
   (compile nil
            '(lambda (a b c)
1650
1651
1652
1653
               (declare (type (integer 0 1000) a b c))
               (if (and (if b (not (and (not (or a t)) nil)) nil)
                        (logbitp 6 c))
                   c b)))
1654
   0 100 600)
1655
  600)
1656
1657
1658
1659

(deftest misc.116
  (funcall
   (compile nil
1660
1661
1662
1663
            '(lambda (a c)
               (declare (type (integer 0 1000) a c))
               (if (if (and (not (and (not (or a t)) nil)) t) c nil)
                   91 -1725615)))
1664
1665
1666
1667
1668
1669
   0 0)
  91)

(deftest misc.117
  (funcall
   (compile nil
1670
1671
1672
1673
            '(lambda (a c)
               (declare (type (integer 0 1000) a c))
               (if (or c (not (or nil (not (and (not (or a t)) nil)))))
                   373146181 115)))
1674
1675
   0 0)
  373146181)
1676
1677
1678
1679

(deftest misc.118
  (funcall
   (compile nil '(lambda (a)
1680
1681
                   (declare (type (integer 0 10000) a))
                   (if (or (or nil (not (or (not (or a nil)) t))) a) a 9376)))
1682
1683
1684
   0)
  0)

1685
1686
1687
1688
1689
1690
(deftest misc.119
  (funcall
   (compile
    nil
    '(lambda ()
       (if (and (if (1+ 0) nil (not (and (not (and (<= 3) nil)) nil)))
1691
1692
                (if (= -31) -20 -2371))
           1493 39720))))
1693
1694
1695
1696
1697
1698
1699
1700
1701
  39720)

(deftest misc.120
  (funcall
   (compile
    nil
    '(lambda (c)
       (declare (type (integer 377036 4184626) c))
       (if (or (and t (not (and (not (and c nil)) nil))) nil)
1702
           3470653 c)))
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
   1000000)
  3470653)

(deftest misc.121
  (funcall
   (compile
    nil
    '(lambda (a b c)
       (if (and (and -92220 (not (and (not (or c nil)) nil))) a) b b)))
   2000000 150000 -1)
  150000)

;;; CAR: #:G243 is not a LIST
(deftest misc.122
  (funcall
   (compile
    nil
    '(lambda (a b c)
       (declare (type (integer 2872749 5754655) a))
       (declare (type (integer 24114340 89504792) b))
       (declare (type (integer 506491 1412971) c))
       (declare (ignorable a b c))
       (declare (optimize (speed 3)))
       (declare (optimize (safety 1)))
       (declare (optimize (debug 1)))
       (- (let ((v7 (ignore-errors a))) -6)
          (logand (if c -13936 c)
                  (block b3 (if (if (or t b) (not nil) c)
                                (return-from b3 -3114)
                              (ignore-errors 7)
                              ))))))
   3000000 30000000 600000)
  15978)

;;; gcl bug (30 Oct 2003)
(deftest misc.123
  (let* ((fn1 '(lambda (b)