misc.lsp 366 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
;-*- 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.
;;;

11

12

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
  4034985990)
sds's avatar
sds committed
637

638 639 640 641 642 643

(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)
sds's avatar
sds committed
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)

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)
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)
1638 1639
                               (if (not (not (if (not nil) t (ldb-test (byte 2 27) 253671809))))
                                   (return-from b2 -22)
1640 1641
                                 (%f1))))))))
   777595384624 -1510893868)
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)
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754
                 (declare (optimize (safety 1)))
                 (labels ((%f7 (f7-1 f7-2)
                               (let ((v2 (setq b 723149855)))
                                 25620)))
                   (max b
                        (multiple-value-call #'%f7 (values b 2))))))
         (fn2 '(lambda (b)
                 (labels ((%f7 (f7-1 f7-2)
                               (let ((v2 (setq b 723149855)))
                                 25620)))
                   (max b
                        (multiple-value-call #'%f7 (values b 2))))))
         (vals '(1439719153))
         (v1 (apply (compile nil fn1) vals))
         (v2 (apply (compile nil fn2) vals)))
1755 1756 1757 1758 1759
    (if (eql v1 v2) :good (list v1 v2)))
  :good)

(deftest misc.124
  (let* ((fn1 '(lambda (b)
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
                 (declare (optimize (safety 1)))
                 (labels ((%f7 (f7-1 f7-2)
                               (let ((v2 (setq b 723149855)))
                                 25620)))
                   (max b
                        (funcall #'%f7 b 2)))))
         (fn2 '(lambda (b)
                 (labels ((%f7 (f7-1 f7-2)
                               (let ((v2 (setq b 723149855)))
                                 25620)))
                   (max b
                        (funcall #'%f7 b 2)))))
         (vals '(1439719153))
         (v1 (apply (compile nil fn1) vals))
         (v2 (apply (compile nil fn2) vals)))
1775 1776 1777 1778 1779 1780
    (if (eql v1 v2) :good (list v1 v2)))
  :good)

;;; This passed in gcl, but I added it for completeness.
(deftest misc.125
  (let* ((fn1 '(lambda (b)
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795
                 (declare (optimize (safety 1)))
                 (labels ((%f7 (f7-1 f7-2)
                               (let ((v2 (setq b 723149855)))
                                 25620)))
                   (max b
                        (%f7 b 2)))))
         (fn2 '(lambda (b)
                 (labels ((%f7 (f7-1 f7-2)
                               (let ((v2 (setq b 723149855)))
                                 25620)))
                   (max b
                        (%f7 b 2)))))
         (vals '(1439719153))
         (v1 (apply (compile nil fn1) vals))
         (v2 (apply (compile nil fn2) vals)))
1796 1797 1798 1799
    (if (eql v1 v2) :good (list v1 v2)))
  :good)


1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
;;; clisp optional argument bug: "SYMBOL-VALUE: 1 is not a SYMBOL"

(deftest misc.126
  (funcall
   (compile
    nil
    '(lambda ()
       (declare (special *should-always-be-true*))
       (labels ((%f10 (f10-1 &optional
                             (f10-2 (cl:handler-bind nil
1810 1811 1812 1813
                                                     (if *should-always-be-true*
                                                         (progn 878)
                                                       (should-never-be-called)
                                                       )))
1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824
                             (f10-3 (cl:handler-case 10)))
                      -15))
         (%f10 -144)))))
  -15)

(deftest misc.127
  (funcall
   (compile
    nil
    '(lambda (a c)
       (flet ((%f10 (f10-1 f10-2) 10))
1825 1826 1827 1828 1829 1830 1831 1832 1833
         (flet ((%f4
                 (&optional
                  (f4-1 (ldb (byte 10 6)
                             (* 828
                                (+ 30 (dpb c (byte 9 30) (%f10 1918433 34107)))
                                )))
                  (f4-2 (setq a 0)))
                 2))
           (%f4 -5)))))
1834 1835 1836
   0 0)
  2)

pfdietz's avatar
pfdietz committed
1837 1838 1839 1840 1841
;;; cmucl (22 Oct 2003 build) bug
;;; The assertion (EQ (C::COMPONENT-KIND C:COMPONENT) :INITIAL) failed.

(deftest misc.128
  (flet ((%f14
1842 1843 1844 1845 1846 1847
          (f14-1 f14-2
                 &optional
                 (f14-3 (unwind-protect 13059412))
                 (f14-4 452384)
                 (f14-5 -6714))
          -1))
pfdietz's avatar
pfdietz committed
1848 1849 1850 1851 1852
    (%f14 -2 1 1279896 589726354 -11))
  -1)

(deftest misc.129
  (labels ((%f17 (f17-1 f17-2 &optional (f17-3 (unwind-protect 178)))
1853
                 483633925))
pfdietz's avatar
pfdietz committed
1854 1855 1856 1857 1858
    -661328075)
  -661328075)

(deftest misc.130
  (let* ((fn1
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
          '(lambda (a c)
             (flet ((%f10 (&optional (f10-1 -6489) (f10-2 (+ c)))
                          a))
               (multiple-value-call #'%f10 (values -178858 a)))))
         (fn2
          '(lambda (a c)
             (declare (notinline values +) (optimize (speed 0) (debug 0)))
             (flet ((%f10 (&optional (f10-1 -6489) (f10-2 (+ c)))
                          a))
               (multiple-value-call #'%f10 (values -178858 a)))))
         (vals '(-13649921 -1813684177409))
         (v1 (apply (compile nil fn1) vals))
         (v2 (apply (compile nil fn2) vals)))
pfdietz's avatar
pfdietz committed
1872 1873 1874 1875 1876
    (if (eql v1 v2) :good (list v1 v2)))
  :good)

(deftest misc.131
  (let* ((fn1
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897
          '(lambda (a b)
             (max
              (block b7
                (abs
                 (ignore-errors
                   (if (ldb-test (byte 33 15) (return-from b7 a))
                       b b)))))))
         (fn2
          '(lambda (a b)
             (declare (notinline abs max))
             (declare (optimize (speed 0)))
             (declare (optimize (debug 0)))
             (max
              (block b7
                (abs
                 (ignore-errors
                   (if (ldb-test (byte 33 15) (return-from b7 a))
                       b b)))))))
         (vals '(-823894140303 -3))
         (v1 (apply (compile nil fn1) vals))
         (v2 (apply (compile nil fn2) vals)))
pfdietz's avatar
pfdietz committed
1898
    (if (eql v1 v2) :good (list v1 v2)))
sds's avatar
sds committed
1899
  :good)
pfdietz's avatar
pfdietz committed
1900 1901 1902 1903 1904 1905 1906 1907 1908

;;; cmucl (22 Oct 2003)
;;; The assertion (EQ C::ENV
;;;                   (C::LAMBDA-ENVIRONMENT
;;;                      (C::LAMBDA-VAR-HOME C::THING))) failed.

(deftest misc.132
  (funcall
   (compile nil
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927
            '(lambda (b c)
               (declare (type (integer -3358662 7782429) b))
               (declare (type (integer -513018 12740) c))
               (declare (optimize (speed 3)))
               (declare (optimize (safety 1)))
               (declare (optimize (debug 1)))
               (labels ((%f9
                         (&optional
                          (f9-1
                           (labels
                               ((%f5 (f5-1 f5-2)
                                     (floor (ignore-errors f5-1)
                                            (min -67 (if (equal -56 c)
                                                         -11197265 f5-2)))))
                             c))
                          (f9-2 -439518)
                          (f9-3 -2840573))
                         f9-1))
                 (%f9 -193644 b 1368))))
pfdietz's avatar
pfdietz committed
1928 1929 1930
   10 20)
  -193644)

1931 1932 1933 1934 1935 1936 1937
(deftest misc.132a
  (funcall
   (compile
    nil
    '(lambda ()
       (declare (optimize (speed 2) (space 0) (safety 0) (debug 2) (compilation-speed 0)))
       (labels ((%f1 () 0))
1938
         (if t 0 (dotimes (iv1 5 (if (%f1) 0 0)) (catch 'ct1 0)))))))
1939 1940
  0)

pfdietz's avatar
pfdietz committed
1941 1942 1943 1944
;;; cmucl (22 Oct 2003)  Default for optional parameter is improperly chosen
(deftest misc.133
  (funcall
   (compile nil
1945 1946 1947 1948 1949
            '(lambda (a b c)
               (declare (notinline values))
               (declare (optimize (speed 0) (debug 0)))
               (flet ((%f15 (&optional (f15-5 c)) f15-5))
                 (multiple-value-call #'%f15 (values -2688612)))))
pfdietz's avatar
pfdietz committed
1950 1951
   1 2 3)
  -2688612)
1952 1953 1954 1955 1956 1957 1958 1959 1960

;;; ACL 6.2 (x86 linux trial) bugs
;;; With optional flet/labels parameters, there's a very high frequency bug
;;; causing the compiler error "Error: `:INFERRED' is not of the expected
;;; type `NUMBER'".  The following tests show this bug.

(deftest misc.134
  (funcall
   (compile nil
1961 1962 1963 1964 1965 1966 1967
            '(lambda (b)
               (labels ((%f5 (f5-1 f5-2 f5-3 &optional (f5-4 0)
                                   (f5-5
                                    (flet ((%f13 (f13-1)
                                                 (return-from %f13 b))) b)))
                             900654472))
                 183301)))
1968 1969 1970 1971 1972 1973
   13775799184)
  183301)

(deftest misc.135
  (funcall
   (compile nil
1974 1975 1976 1977
            '(lambda (a b)
               (labels ((%f4 (&optional (f4-1 (labels ((%f17 nil a)) b)))
                             -14806404))
                 190134)))
1978 1979 1980 1981 1982 1983
   1783745644 268410629)
  190134)

(deftest misc.136
  (funcall
   (compile nil
1984 1985 1986 1987 1988
            '(lambda (c)
               (flet ((%f17 (&optional
                             (f17-1 (flet ((%f9 nil c)) 73574919)))
                            643))
                 1039017546)))
1989 1990 1991 1992 1993 1994 1995 1996
   0)
  1039017546)

;;; And these caused segfaults

(deftest misc.137
  (funcall
   (compile nil
1997 1998 1999 2000 2001 2002 2003 2004
            '(lambda ()
               (declare (optimize (speed 3)))
               (declare (optimize (safety 1)))
               (flet ((%f16 (&optional
                             (f16-2 (lognor -3897747
                                            (if nil -1 -127228378))))
                            10))
                 20))))
2005 2006 2007 2008 2009
  20)

(deftest misc.138
  (funcall
   (compile nil
2010 2011 2012 2013 2014 2015 2016 2017 2018
            '(lambda (c)
               (declare (type (integer 2996 39280) c))
               (declare (optimize (speed 3)))
               (declare (optimize (safety 1)))
               (if (zerop (labels ((%f8 (&optional
                                         (f8-2 (logorc2 c -161957)))
                                        2176))
                            3))
                   c c)))
2019 2020
   3000)
  3000)
2021 2022 2023 2024 2025 2026

;;; Lispworks 4.2 (x86 linux personal edition) failures


(deftest misc.139
  (let* ((fn1
2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
          '(lambda (c)
             (declare (optimize (speed 3)))
             (logior (labels ((%f1 (f1-1 &optional (f1-2 (setq c 7))) f1-1))
                       (%f1 774 3616592)) c)))
         (fn2
          '(lambda (c)
             (logior (labels ((%f1 (f1-1 &optional (f1-2 (setq c 7))) f1-1))
                       (%f1 774 3616592)) c)))
         (vals '(-3))
         (v1 (apply (compile nil fn1) vals))
         (v2 (apply (compile nil fn2) vals)))
2038 2039 2040 2041 2042 2043
    (if (eql v1 v2) :good (list v1 v2)))
  :good)

(deftest misc.140
  (funcall
   (compile nil
2044 2045 2046 2047
            '(lambda (a)
               (ldb (byte 24 20)
                    (labels ((%f12 (&optional (f12-1 149) (f12-2 -3894159)) 34068))
                      (let* ((v4 (%f12))) a)))))
2048 2049
   -1)
  16777215)
sds's avatar
sds committed
2050

2051 2052 2053 2054 2055 2056 2057

;;; In Lispworks 4.2 (x86 linux personal edition)
;;; 'Error: *** Ran out of patterns in (MOVE) for (edi NIL)'

(deftest misc.141
  (funcall
   (compile nil
2058 2059
            '(lambda () (labels ((%f11 (&optional (f11-3 (restart-case 0))) f11-3))
                          (%f11 1)))))
2060 2061 2062 2063 2064
  1)

(deftest misc.142
  (funcall
   (compile nil
2065 2066 2067 2068
            '(lambda ()
               (labels ((%f15 (&optional (f15-3 (block b1 (+ 1 (return-from b1 -10)))))
                              f15-3))
                 (%f15)))))
2069 2070
  -10)

2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081
;;; cmucl (22 Oct 2003):  NIL is not of type C::REF
(deftest misc.143
  (block b2
      (max (return-from b2 1)
           (let ((v3
                  (unwind-protect
                      (let* ((v1 (ignore-errors -254)))
                        1))))
             -2)))
  1)

pfdietz's avatar
pfdietz committed
2082 2083 2084
;;; (was) The assertion (NOT (C::BLOCK-DELETE-P BLOCK)) failed.
;;; (now) The assertion (NOT (MEMBER C::KIND '(:DELETED :OPTIONAL :TOP-LEVEL))) failed.

2085 2086 2087
(deftest misc.144
  (funcall
   (compile nil
2088 2089 2090 2091 2092 2093 2094
            '(lambda (a b c)
               (declare (type (integer 9739325 14941321) c))
               (labels ((%f7 (f7-1 f7-2 f7-3 &optional (f7-4 b))
                             (return-from %f7 f7-4)))
                 (if (= -76482 c)
                     (if (>= c 10986082) (%f7 a b (%f7 -8088 c -147106 2)) -10502)
                   (%f7 509252 b b)))))
2095 2096 2097 2098 2099 2100
   -200 17 10000000)
  17)

(deftest misc.145
  (funcall
   (compile nil
2101 2102 2103 2104 2105
            '(lambda (a b c)
               (declare (optimize (safety 3)))
               (block b5
                 (return-from b5
                   (logior (if (or c t) b (load-time-value -61)) (return-from b5 -3))))))
2106 2107 2108 2109 2110 2111 2112
   1 2 3)
  -3)

;;; cmucl: order of evaluation error
(deftest misc.146
  (funcall
   (compile nil
2113 2114 2115 2116 2117 2118
            '(lambda (b)
               (declare (optimize (speed 3)))
               (flet ((%f14 (&optional (f14-1 301917227)
                                       (f14-2 (setq b 995196571)))
                            f14-1))
                 (%f14 b (block b3 (%f14 -64))))))
2119 2120 2121 2122 2123 2124 2125
   10)
  10)

;;; cmucl (22 Oct 2003): NIL is not of type C::CLEANUP
(deftest misc.147
  (flet ((%f11 () (if nil (ignore-errors -19884254) (unwind-protect -2)))) :good)
  :good)
2126

2127 2128 2129 2130
;;; The assertion (C::CONSTANT-CONTINUATION-P C::CONT) failed.
(deftest misc.148
  (block b2 (logior (return-from b2 484) (restart-case (ignore-errors 1737021))))
  484)
2131

pfdietz's avatar
pfdietz committed
2132 2133 2134 2135
;;; Argument X is not a NUMBER: NIL.
(deftest misc.149
  (funcall
   (compile nil '(lambda (b)
2136
                   (block b1 (- (logand 0 -34 1026491) (ignore-errors (return-from b1 b))))))
pfdietz's avatar
pfdietz committed
2137 2138 2139
   0)
  0)

pfdietz's avatar
pfdietz committed
2140 2141 2142 2143 2144 2145
(deftest misc.149a
  (funcall
   (compile nil '(lambda (a) (block b1 (- a (ignore-errors (return-from b1 1))))))
   0)
  1)

pfdietz's avatar
pfdietz committed
2146 2147 2148 2149 2150 2151 2152
;;; cmucl (11 2003 image)  "NIL is not of type C::CONTINUATION"
(deftest misc.150
  (funcall
   (compile
    nil
    '(lambda (a b c)
       (flet ((%f17
2153 2154 2155 2156 2157 2158 2159
               (&optional
                (f17-4
                 (labels ((%f13 (f13-1 &optional (f13-2 (multiple-value-prog1 b)))
                                -4))
                   (%f13 b (%f13 190)))))
               -157596))
         (labels ((%f6 () (%f17))) c))))
pfdietz's avatar
pfdietz committed
2160 2161 2162
   10 20 30000)
  30000)

2163 2164 2165 2166 2167 2168
(deftest misc.150a
  (funcall
   (compile
    nil
    '(lambda ()
       (declare (optimize (speed 3) (space 2) (safety 3)