From b8a9cf638df96d28ae692694de88e4c43bc9f982 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Tue, 6 Dec 2011 00:36:51 +0200 Subject: [PATCH] fix doubled unboxed constants when there is no immediate representation 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 | 6 ++++-- tests/compiler.pure.lisp | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/compiler/tn.lisp b/src/compiler/tn.lisp index 1f72696..a94c585 100644 --- a/src/compiler/tn.lisp +++ b/src/compiler/tn.lisp @@ -211,8 +211,10 @@ ;; 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* diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 52e4c12..dd0cb16 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -4121,6 +4121,14 @@ (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 -- 1.7.10.4