wanted: elide vector bounds checking for (min x (length v)) or generally index < x <= length

Bug #1830313 reported by 3b
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

sbcl can elide bounds checks when it knows (< index (length vector)), but not more complicated cases.

When iterating over part of a vector, it would be nice to also skip checks when the end is known to be in bounds.
for example:

(loop for i below (min x (length v)) ... (aref v i))
or
(assert (<= x (length v)))
(loop for i below x ... (aref v i))

doesn't have to be completely general as long as there is some reasonable idiom for specifying it should be true, assuming the compiler can verify it quickly even if it can't derive it.

Revision history for this message
3b (00003b) wrote :

see also bug #1830314

Revision history for this message
Stas Boukarev (stassats) wrote :

Some past commit has addressed this.

Changed in sbcl:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.