logo       

Re: ffloor-derived-type-optimizer: msg#00284

lisp.cmucl.devel

Subject: Re: ffloor-derived-type-optimizer

>>>>> "Gerd" == Gerd Moellmann <gerd.moellmann@xxxxxxxxxxx> writes:

Gerd> gerd.moellmann@xxxxxxxxxxx (Gerd Moellmann) writes:
>> (defun foo (n d)
>> (declare (type (unsigned-byte 32) n d))
>> (ffloor n d))

[snip]

Gerd> That's why Python thinks FOO's return type is NIL. Compiling the file
Gerd> natively, C::FFLOOR-DERIVE-TYPE-OPTIMIZER is not called, which
Gerd> probably explains the difference in behavior.

I wonder why ffloor defoptimizer isn't called when compiling natively?

Gerd> Someone knowing that part of the code intimately enough to spot the
Gerd> bug immediately?

This is probably caused by this bit:

(defun ,q-aux (number-type divisor-type)
(let* ((number-interval
(numeric-type->interval number-type))
(divisor-interval
(numeric-type->interval divisor-type))
(quot (,q-name (interval-div number-interval
divisor-interval)))
(res-type (numeric-contagion number-type divisor-type)))

Since number-type and divisor-type are integers, res-type is rational.
Since we want a float result, we could test if res-type is not a float
of some sort (single-float/double-float) convert it to a float type
before returning the desired quotient type.

This was probably caused by too much cutting and pasting from the
floor/ceiling defoptimizers.

Ray




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise