fix doubled unboxed constants when there is no immediate representation
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 5 Dec 2011 22:36:51 +0000 (00:36 +0200)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 5 Dec 2011 23:44:09 +0000 (01:44 +0200)
  The recent changes to handling of boxed constants indvertently cause them to
  be duplicated when there was not immediate representation at all, and both an
  unboxed and a boxed representaion would have been desirable.

src/compiler/tn.lisp
tests/compiler.pure.lisp

index 1f72696..a94c585 100644 (file)
       ;; However, in the case of USE-IMMED-P we can have the same TN for both
       ;; uses. The first two legs here take care of that by cross-pollinating the
       ;; cached values.
-      ((and use-immed-p boxedp (leaf-info constant)))
-      ((and use-immed-p (not boxedp) (constant-boxed-tn constant)))
+      ;;
+      ;; Similarly, when there is no immediate SC.
+      ((and (or use-immed-p (not immed)) boxedp (leaf-info constant)))
+      ((and (or use-immed-p (not immed)) (not boxedp) (constant-boxed-tn constant)))
       (t
        (let* ((component (component-info *component-being-compiled*))
               (sc (svref *backend-sc-numbers*
index 52e4c12..dd0cb16 100644 (file)
                          (unknown-fun 1.0d0 (+ 1.0d0 x))))))
     (assert (equal '(1.0d0) (ctu:find-code-constants fun :type 'double-float)))))
 
+(with-test (:name :only-one-boxed-constant-for-multiple-uses)
+  (let* ((big (1+ most-positive-fixnum))
+         (fun (compile nil
+                       `(lambda (x)
+                          (unknown-fun ,big (+ ,big x))))))
+    (assert (equal (list 0 (1+ most-positive-fixnum))
+                   (ctu:find-code-constants fun :type t)))))
+
 (with-test (:name :fixnum+float-coerces-fixnum
             :skipped-on :x86)
   (let ((fun (compile nil