Re: SBCL tells me it is deleting unreachable code that is almost surely reachable
Barton Willis via Maxima-discuss <[email protected]>
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <SN6PR07MB79525F8439F019B40D3EA6E8B6222@SN6PR07MB7952.namprd07.prod.outlook.com> |
Thanks -- ((member sgn '($neg $zero $pos)) sgn) eliminates the message. --Barton ________________________________ From: Stavros Macrakis <[email protected]> Sent: Wednesday, April 15, 2026 12:12 PM To: Raymond Toy <[email protected]> Cc: [email protected] <[email protected]> Subject: Re: [Maxima-discuss] SBCL tells me it is deleting unreachable code that is almost surely reachable Caution: Non-NU Email 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]<mailto:[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 list [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/maxima-discuss<https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/maxima-discuss__;!!PvXuogZ4sRB2p-tU!CTeVWX009wUTo0lZH_9Xgh0ZBW2sdmp1KOEGAg5dr8jd1dNtEpR7-c_b6JlJyKD94x1sJ4mpIE7-iiE$> ​ _______________________________________________ Maxima-discuss mailing list [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/maxima-discuss<https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/maxima-discuss__;!!PvXuogZ4sRB2p-tU!CTeVWX009wUTo0lZH_9Xgh0ZBW2sdmp1KOEGAg5dr8jd1dNtEpR7-c_b6JlJyKD94x1sJ4mpIE7-iiE$> _______________________________________________ Maxima-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/maxima-discuss