Fix make-array transforms.
[sbcl.git] / src / compiler / generic / vm-tran.lisp
index c4044a3..f390c6f 100644 (file)
                               index offset &optional setter-p)
   (multiple-value-bind (func index-args) (extract-fun-args index '(+ -) 2)
     (destructuring-bind (x constant) index-args
-      (declare (ignorable x))
-      (unless (constant-lvar-p constant)
+      (unless (and (constant-lvar-p constant)
+                   ;; we lose if the remaining argument isn't a fixnum
+                   (csubtypep (lvar-type x) (specifier-type 'fixnum)))
         (give-up-ir1-transform))
-      (let ((value (lvar-value constant)))
+      (let ((value (lvar-value constant))
+            new-offset)
         (unless (and (integerp value)
                      (sb!vm::foldable-constant-offset-p
                       element-size lowtag data-offset
-                      (funcall func value (lvar-value offset))))
+                      (setf new-offset (funcall func (lvar-value offset)
+                                                value))))
           (give-up-ir1-transform "constant is too large for inlining"))
         (splice-fun-args index func 2)
         `(lambda (thing index off1 off2 ,@(when setter-p
                                             '(value)))
-           (,fun-name thing index (,func off2 off1) ,@(when setter-p
-                                                        '(value))))))))
+           (declare (ignore off1 off2))
+           (,fun-name thing index ',new-offset ,@(when setter-p
+                                                   '(value))))))))
 
 #!+(or x86 x86-64)
 (deftransform sb!bignum:%bignum-ref-with-offset
 (define-source-transform %set-funcallable-instance-layout (x val)
   `(setf (%funcallable-instance-info ,x 0) (the layout ,val)))
 \f
-;;;; character support
-
-;;; In our implementation there are really only BASE-CHARs.
-#+nil
-(define-source-transform characterp (obj)
-  `(base-char-p ,obj))
-\f
 ;;;; simplifying HAIRY-DATA-VECTOR-REF and HAIRY-DATA-VECTOR-SET
 
 (deftransform hairy-data-vector-ref ((string index) (simple-string t))