From: Nikodemus Siivola Date: Thu, 14 May 2009 10:23:47 +0000 (+0000) Subject: 1.0.28.47: depessimize accesses to maybe non-simple arrays with known element types X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=8f571a2c80ba0de2a69f6a142d149d3838412a28;p=sbcl.git 1.0.28.47: depessimize accesses to maybe non-simple arrays with known element types The transforms for HAIRY-DATA-VECTOR-(REF|SET) which inserted a call to %DATA-VECTOR-AND-INDEX were never a win unless the array was known to be simple: the element type dispatch is quite effcient, and the slow path has an open coded WITH-ARRAY-DATA which performs better. For simple arrays the transforms remain a win, since %DATA-VECTOR-AND-INDEX will be open coded: at most one dereference is ever necessary. Unfortunately declaring the element type of a non-simple array remains a loss -- just a less drastic one then before. --- diff --git a/NEWS b/NEWS index f37703e..bad4a4b 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ the symbol, prohibits both lexical and dynamic binding. This is mainly an efficiency measure for threaded platforms, but also valueable in expressing intent. + * optimization: accesses to potentially non-simple arrays where element type + is known are 50% faster. * optimization: compiler now generates faster array typechecking code. * optimization: ARRAY-DIMENSION is now faster for multidimensional and non-simple arrays. diff --git a/src/compiler/generic/vm-tran.lisp b/src/compiler/generic/vm-tran.lisp index 3aef253..5b37876 100644 --- a/src/compiler/generic/vm-tran.lisp +++ b/src/compiler/generic/vm-tran.lisp @@ -106,7 +106,11 @@ ((simple-array nil (*)) (data-vector-ref string index)))))) -(deftransform hairy-data-vector-ref ((array index) (array t) *) +;;; This and the corresponding -SET transform work equally well on non-simple +;;; arrays, but after benchmarking (on x86), Nikodemus didn't find any cases +;;; where it actually helped with non-simple arrays -- to the contrary, it +;;; only made for bigger and up 1o 100% slower code. +(deftransform hairy-data-vector-ref ((array index) (simple-array t) *) "avoid runtime dispatch on array element type" (let ((element-ctype (extract-upgraded-element-type array)) (declared-element-ctype (extract-declared-element-type array))) @@ -188,8 +192,12 @@ ((simple-array nil (*)) (data-vector-set string index new-value)))))) +;;; This and the corresponding -REF transform work equally well on non-simple +;;; arrays, but after benchmarking (on x86), Nikodemus didn't find any cases +;;; where it actually helped with non-simple arrays -- to the contrary, it +;;; only made for bigger and up 1o 100% slower code. (deftransform hairy-data-vector-set ((array index new-value) - (array t t) + (simple-array t t) *) "avoid runtime dispatch on array element type" (let ((element-ctype (extract-upgraded-element-type array)) diff --git a/version.lisp-expr b/version.lisp-expr index e7e08d5..5056fe2 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.28.46" +"1.0.28.47"