Generic LOGTEST conses even when given fixnum arguments.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Low
|
Unassigned |
Bug Description
See this transcript (SBCL 1.1.15.33-142dc0d on Linux/x86-64):
* (defun f (g)
(let ((x 0))
(dotimes (i 100000)
(when (funcall g i)
(incf x)))
x))
F
* (let ((before (sb-ext:
(f #'(lambda (i) (logtest i 1)))
(- (sb-ext:
12779520
This is bad because (LOGTEST X 1) is used in ODDP which is used in INTEXP, so the generic ODDP and EXPT (and EVENP and surely more) on fixnums all cons unnecessarily.
ROOM shows that the consing consists of bignums:
* (room)
[…]
12,551,712 bytes for 647,394 bignum objects.
[…]
This is a regression. (Before the regression the second expression above returned 0 and ROOM shows no bignums). I have bisected it to sbcl-1.
a8419eb994f3b
commit a8419eb994f3b59
Author: Paul Khuong <email address hidden>
Date: Fri Jun 7 18:46:25 2013 -0400
Complete cut-to-width for modular arithmetic
For each modular argument, go through the nodes that provide its
value and try to narrow down their bitwidth. If we fail on any and
the result might be too wide, splice in an explicit call to LOGAND
or MASK-SIGNED-FIELD. Skip that last step if the value is an argument
to an equivalent LOGAND or MASK-SIGNED-FIELD.
Test case by Eric Marsden.
Disassembling ODDP shows a call to TWO-ARG-AND in the SBCL versions before
this commit and a call to SB-C::MASK-
Greetings,
Lutz
Changed in sbcl: | |
status: | New → Triaged |
importance: | Undecided → Low |
Changed in sbcl: | |
status: | Triaged → Fix Committed |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
In case anyone wants to investigate this: There was some discussion on #sbcl about this on 2014-02-07 and 2014-02-08.
Regards,
Lutz