From: Alexey D. <ade...@us...> - 2005-06-13 11:06:03
|
Update of /cvsroot/sbcl/sbcl/src/compiler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2455/src/compiler Modified Files: fndb.lisp typetran.lisp Log Message: 0.9.1.40: * COERCE for objects other than numbers and characters is not foldable (fix a bug reported by Nikodemus Siivola). * Set LC_ALL to "C" when building SBCL. * Set locale to "C" in run-tests.sh. Index: fndb.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/fndb.lisp,v retrieving revision 1.104 retrieving revision 1.105 diff -u -d -r1.104 -r1.105 --- fndb.lisp 8 Jun 2005 10:36:17 -0000 1.104 +++ fndb.lisp 13 Jun 2005 11:05:51 -0000 1.105 @@ -17,24 +17,8 @@ (defknown coerce (t type-specifier) t ;; Note: - ;; (1) This is not FLUSHABLE because it's defined to signal errors. - ;; (2) It's not worth trying to make this FOLDABLE in the - ;; cross-compiler,because - ;; (a) it would probably be really hard to make all the - ;; tricky issues (e.g. which specialized array types are - ;; supported) match between cross-compiler and target - ;; compiler, and besides - ;; (b) leaving it not FOLDABLE lets us use the idiom - ;; (COERCE FOO 'SOME-SPECIALIZED-ARRAY-TYPE-OR-ANOTHER) - ;; as a way of delaying the generation of specialized - ;; array types until runtime, which helps us keep the - ;; cross-compiler's dumper relatively simple and which - ;; lets us preserve distinctions which might not even exist - ;; on the cross-compilation host (because ANSI doesn't - ;; guarantee that specialized array types exist there). - ;; FIXME: It's actually not clear that COERCE on non-NUMBER types - ;; is FOLDABLE at all. Check this. - (movable #-sb-xc-host foldable) + ;; This is not FLUSHABLE because it's defined to signal errors. + (movable) ;; :DERIVE-TYPE RESULT-TYPE-SPEC-NTH-ARG 2 ? Nope... (COERCE 1 'COMPLEX) ;; returns REAL/INTEGER, not COMPLEX. ) Index: typetran.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/typetran.lisp,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- typetran.lisp 7 Apr 2005 12:32:56 -0000 1.46 +++ typetran.lisp 13 Jun 2005 11:05:51 -0000 1.47 @@ -537,6 +537,16 @@ ;;;; coercion +;;; Constant-folding. +;;; +#-sb-xc-host +(defoptimizer (coerce optimizer) ((x type) node) + (when (and (constant-lvar-p x) (constant-lvar-p type)) + (let ((value (lvar-value x))) + (when (or (numberp value) (characterp value)) + (constant-fold-call node) + t)))) + (deftransform coerce ((x type) (* *) * :node node) (unless (constant-lvar-p type) (give-up-ir1-transform)) |