This reverts commit
5d3a728a1d9a91e7218fe53f12f96ab63b846810.
The current code is still wrong, but better the bugs we've always had
than the ones that break currently-working code.
Kept the test case, and added the one we failed on.
about a constant NIL (similar for non-EQ-comparable catch tags).
* bug fix: Referring to INLINE global functions as values should not result
in a compilation failure. (lp#1035721)
about a constant NIL (similar for non-EQ-comparable catch tags).
* bug fix: Referring to INLINE global functions as values should not result
in a compilation failure. (lp#1035721)
- * bug fix: Known-safe vector access on x86oids should not fail spuriously
- when the index is of the form (+ x constant-positive-integer).
* optimization: faster ISQRT on fixnums and small bignums
* optimization: faster and smaller INTEGER-LENGTH on fixnums on x86-64.
* optimization: On x86-64, the number of multi-byte NOP instructions used
* optimization: faster ISQRT on fixnums and small bignums
* optimization: faster and smaller INTEGER-LENGTH on fixnums on x86-64.
* optimization: On x86-64, the number of multi-byte NOP instructions used
(movable foldable flushable dx-safe))
(defknown data-vector-ref (simple-array index) t
(foldable explicit-check always-translatable))
(movable foldable flushable dx-safe))
(defknown data-vector-ref (simple-array index) t
(foldable explicit-check always-translatable))
-(defknown data-vector-ref-with-offset (simple-array fixnum fixnum) t
+(defknown data-vector-ref-with-offset (simple-array index fixnum) t
(foldable explicit-check always-translatable))
(defknown data-vector-set (array index t) t
(explicit-check always-translatable))
(foldable explicit-check always-translatable))
(defknown data-vector-set (array index t) t
(explicit-check always-translatable))
-(defknown data-vector-set-with-offset (array fixnum fixnum t) t
+(defknown data-vector-set-with-offset (array index fixnum t) t
(explicit-check always-translatable))
(defknown hairy-data-vector-ref (array index) t
(foldable explicit-check))
(explicit-check always-translatable))
(defknown hairy-data-vector-ref (array index) t
(foldable explicit-check))
(defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
(flushable))
#!+(or x86 x86-64)
(defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
(flushable))
#!+(or x86 x86-64)
-(defknown %bignum-ref-with-offset (bignum-type fixnum (signed-byte 24))
+(defknown %bignum-ref-with-offset (bignum-type bignum-index (signed-byte 24))
bignum-element-type (flushable always-translatable))
(defknown %bignum-set (bignum-type bignum-index bignum-element-type)
bignum-element-type (flushable always-translatable))
(defknown %bignum-set (bignum-type bignum-index bignum-element-type)
())
#!+(or x86 x86-64)
(defknown %bignum-set-with-offset
())
#!+(or x86 x86-64)
(defknown %bignum-set-with-offset
- (bignum-type fixnum (signed-byte 24) bignum-element-type)
+ (bignum-type bignum-index (signed-byte 24) bignum-element-type)
bignum-element-type (always-translatable))
(defknown %digit-0-or-plusp (bignum-element-type) boolean
bignum-element-type (always-translatable))
(defknown %digit-0-or-plusp (bignum-element-type) boolean
index offset &optional setter-p)
(multiple-value-bind (func index-args) (extract-fun-args index '(+ -) 2)
(destructuring-bind (x constant) index-args
index offset &optional setter-p)
(multiple-value-bind (func index-args) (extract-fun-args index '(+ -) 2)
(destructuring-bind (x constant) index-args
- (unless (and (constant-lvar-p constant)
- ;; the remaining argument must be a fixnum, otherwise we lose
- (csubtypep (lvar-type x) (specifier-type 'fixnum)))
- (delay-ir1-transform :constraint)
+ (declare (ignorable x))
+ (unless (constant-lvar-p constant)
- (let ((value (lvar-value constant))
- new-offset)
+ (let ((value (lvar-value constant)))
(unless (and (integerp value)
(sb!vm::foldable-constant-offset-p
element-size lowtag data-offset
(unless (and (integerp value)
(sb!vm::foldable-constant-offset-p
element-size lowtag data-offset
- (setf new-offset (funcall func (lvar-value offset) value))))
+ (funcall func value (lvar-value offset))))
(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)))
(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)))
- (declare (ignore off1 off2))
- (,fun-name thing index ',new-offset ,@(when setter-p
- '(value))))))))
+ (,fun-name thing index (,func off2 off1) ,@(when setter-p
+ '(value))))))))
#!+(or x86 x86-64)
(deftransform sb!bignum:%bignum-ref-with-offset
#!+(or x86 x86-64)
(deftransform sb!bignum:%bignum-ref-with-offset
(test (- most-positive-fixnum x) y)
(test (+ most-negative-fixnum x) y))))))
(test (- most-positive-fixnum x) y)
(test (+ most-negative-fixnum x) y))))))
-(test-util:with-test (:name :fold-index-addressing-positive-offset)
+;; expected failure
+(test-util:with-test (:name :fold-index-addressing-positive-offset
+ :fails-on '(and))
(let ((f (compile nil `(lambda (i)
(if (typep i '(integer -31 31))
(aref #. (make-array 63) (+ i 31))
(error "foo"))))))
(funcall f -31)))
(let ((f (compile nil `(lambda (i)
(if (typep i '(integer -31 31))
(aref #. (make-array 63) (+ i 31))
(error "foo"))))))
(funcall f -31)))
+
+;; 5d3a728 broke something like this in CL-PPCRE
+(test-util:with-test (:name :fold-index-addressing-potentially-negative-index)
+ (compile nil `(lambda (index vector)
+ (declare (optimize speed (safety 0))
+ ((simple-array character (*)) vector)
+ ((unsigned-byte 24) index))
+ (aref vector (1+ (mod index (1- (length vector))))))))