Re: SBCL tells me it is deleting unreachable code that is almost surely reachable
Stavros Macrakis <[email protected]>
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <CACLVabU521VyRh8pjJVSZzT7HHrnwBtRaYMzUW_O33HXCLhOYA@mail.gmail.com> |
Of course, this:
((memq sgn '($neg *'*$zero *'*$pos)) sgn)
should be
((memq sgn '($neg $zero $pos)) sgn)
and might as well be
((member sgn '($neg $zero $pos)) sgn)
If the compiler is so incompetent that it doesn't recognize it can't use
*eq* for a list of symbols, the compiler should be fixed!
And, as Ray suggests, it will almost certainly inline *member/eq* for a
length-3 list: that is both faster and smaller than calling *member *on
most (all?) Lisp systems.
And *memq* is already declaimed *inline* in *clmacs.lisp*, line 232.
Looking at the generated code, I see that with *optimize speed:0 space:3*,
SBCL calls *member-eq*, even though that takes more space. Apparently it
uses an inaccurate heuristic to estimate space usage.
-s
On Wed, Apr 15, 2026 at 12:10 PM Raymond Toy <[email protected]> wrote:
> On 4/15/26 8:25 AM, Barton Willis via Maxima-discuss wrote:
>
> Here is a revision of a function in hayat. The revision eliminates or
> helps to eliminate two testsuite failures.
>
> The SBCL (2.4.7) compiler tells me that
>
> ; file: C:/Users/barton/maxima-code-pure/maxima-code/src/./hayat.lisp
> ; in: DEFUN COEF-SIGN
> ; (EQ MAXIMA::SGN 'MAXIMA::$POS)
> ;
> ; note: deleting unreachable code
>
> I think that is rubbish—likely, I'll commit the (commented out) memq
> version.
>
> Check to see what $csign returns? Or rather what csign-impl returns. For
> me, I see the return type is * (anything).
>
> memq should do exactly the same as testing (or (eq sgn '$neg) (eq sgn
> '$zero) (eq sgn '$pos)). Well, it would if it were declared inline, but
> it’s not.
>
> Seems to me that it would be easy to test if that code were actually
> deleted by calling coef-sign with an arg that is known to be $pos.
>
>
> (defun coef-sign (coef)
>
> (let ((sgn ($csign coef)))
> (cond ((or (eq sgn '$complex) (eq sgn '$imaginary)) '$im)
> ;((memq sgn '($neg '$zero '$pos)) sgn)
> ((or (eq sgn '$neg) (eq sgn '$zero) (eq sgn '$pos)) sgn)
> (t
> (let ((asgn ($asksign coef)))
> ;; When sgn is zero and limit is active, record this fact
> as a noun equality
> ;; in *limit-assumptions*.
> (when (and *limit-assumptions* (eq asgn '$zero))
> (push (ftake '$equal coef 0) *limit-assumptions*))
> asgn)))))
>
>
>
> _______________________________________________
> Maxima-discuss mailing [email protected]://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
> ​
> _______________________________________________
> Maxima-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss