Skip to content
Snippets Groups Projects
Commit 34547175 authored by dtc's avatar dtc
Browse files

Have the compiler inline complex array access, calling %with-array-data

if necessary. This then allows the inlining of the simple-array accessor
which may reduce consing and may give better performance overall.
parent 9f4a1f5e
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/vm-tran.lisp,v 1.40 2000/09/14 14:34:37 dtc Exp $")
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/generic/vm-tran.lisp,v 1.41 2000/10/21 13:08:49 dtc Exp $")
;;;
;;; **********************************************************************
;;;
......@@ -75,6 +75,31 @@
(%array-data-vector array))
index))))))
(deftransform data-vector-ref ((array index) (array t) *
:node node :policy (> speed space))
(let ((array-type (continuation-type array)))
(unless (and (array-type-p array-type) (array-type-complexp array-type)
(not (eq (array-type-specialized-element-type array-type)
*wild-type*)))
(give-up))
(delay-transform node :optimize)
(let* ((dims (array-type-dimensions array-type))
(el-type (array-type-element-type array-type))
(total-size (if (or (atom dims) (member '* dims))
'*
(reduce #'* dims)))
(vector-type `(simple-array ,(type-specifier el-type)
(,total-size))))
(if (and (consp dims) (> (length dims) 1))
`(multiple-value-bind (vector index)
(%with-array-data array index nil)
(data-vector-ref (truly-the ,vector-type vector) index))
`(multiple-value-bind (vector index)
(if (array-header-p array)
(%with-array-data array index nil)
(values array index))
(data-vector-ref (truly-the ,vector-type vector) index))))))
(deftransform data-vector-set ((array index new-value)
(simple-array t t))
(let ((array-type (continuation-type array)))
......@@ -101,6 +126,35 @@
index
new-value))))))
(deftransform data-vector-set ((array index new-value) (array t t) *
:node node :policy (> speed space))
(let ((array-type (continuation-type array)))
(unless (and (array-type-p array-type) (array-type-complexp array-type)
(not (eq (array-type-specialized-element-type array-type)
*wild-type*)))
(give-up))
(delay-transform node :optimize)
(let* ((dims (array-type-dimensions array-type))
(el-type (array-type-element-type array-type))
(total-size (if (or (atom dims) (member '* dims))
'*
(reduce #'* dims)))
(vector-type `(simple-array ,(type-specifier el-type)
(,total-size))))
(if (and (consp dims) (> (length dims) 1))
`(multiple-value-bind (vector index)
(%with-array-data array index nil)
(data-vector-set (truly-the ,vector-type vector)
index
new-value))
`(multiple-value-bind (vector index)
(if (array-header-p array)
(%with-array-data array index nil)
(values array index))
(data-vector-set (truly-the ,vector-type vector)
index
new-value))))))
;;; Transforms for getting at arrays of unsigned-byte n when n < 8.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment