Optimize integer truncation by constant rationals

Bug #823674 reported by Paul Khuong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Triaged
Wishlist
Unassigned

Bug Description

Generalization/optimization of https://bugs.launchpad.net/bugs/820341 .

I've been doing some thinking, and we can handle (truncate [unsigned-word] (/ [unsigned-word] [unsigned-word])) fairly efficiently when the second argument is constant and the result is an unsigned word.

For an example of efficiency, it takes ~60% as much time to (truncate x (/ (rational pi))) than to (truncate (* x pi)) when only the first return value is computed. The code also includes improvements for regular truncated division, and is able to exploit the range derived for X to generate smaller code sequences than Granlund & Montgomery (i.e. better than gcc ;).

Downside: the patch is on the heavy side (a few hundred LOC, without comments), and exploits unpublished tricks that haven't been verified by anyone else yet.

I'm opening this ticket to update it with the patch's (and documentation's) progress.

Revision history for this message
Paul Khuong (pvk) wrote :
Revision history for this message
Paul Khuong (pvk) wrote :

Seems way too slow to be practical.

Changed in sbcl:
status: New → Won't Fix
assignee: Paul Khuong (pvk) → nobody
Revision history for this message
Paul Khuong (pvk) wrote :

Compiler performance is fine at https://github.com/pkhuong/sbcl/commits/fast-truncate . Hopefully, correct explanation coming up soon.

Changed in sbcl:
status: Won't Fix → In Progress
assignee: nobody → Paul Khuong (pvk)
Paul Khuong (pvk)
Changed in sbcl:
importance: Low → Wishlist
status: In Progress → Triaged
assignee: Paul Khuong (pvk) → nobody
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.