Deleting un(?)reachable code
- From: danb <sogwaldan@xxxxxxxxx>
- Date: Mon, 17 Mar 2008 18:53:49 -0700 (PDT)
Does anyone have any idea why sbcl would delete these
code segments? There are three FORMAT forms and one
CDR form.
The FORMATs occur in an inlined function (USABLE), and are
called conditionally, depending on the value of an optional arg
(TESTING). I understand that the conditional calls can be elim-
inated for any call to the inline function that doesn't specify
a value for the condition, which defaults to nil. But there's
still some strangeness left over:
1. Why does the compiler single out the format strings as
being the unreachable part?
2. Why aren't the PAUSE forms eliminated, since they're in
the same WHEN forms as the FORMATs?
3. Why is the (cdr cell) form that's called inside the
(while (cdr cell) ...) form eliminated? An obvious thought
would be that I got the test backwards in WHILE, but it's tested
and seems to work. The conditional test in WHILE is
(unless ,test (return-from ,block))
I don't see how that could be wrong.
(compiler output & code snippets below;
affected code is under-careted)
--Dan
Compiler output:
; in: DEF-INLINE USABLE
; (FORMAT T "n-div = ~D. " PANPAL::N-DIV)
; ==> "n-div = ~D. "
; note: deleting unreachable code
; (FORMAT T "~A is usable.~%" PANPAL::WORD)
; ==> "~A is usable.~%"
; note: deleting unreachable code
; (FORMAT T "~A is not usable.~%" PANPAL::WORD)
; ==> "~A is not usable.~%"
; note: deleting unreachable code
; in: DEF TRIM-WORDS
; (CDR PANPAL::CELL)
; ==> PANPAL::CELL
; note: deleting unreachable code
Code snippets:
(def-inline usable (word fortree baktree &optional verbose)
...
(dotimes (n-div (1- num-chars))
(when verbose
(format t "n-div = ~D. " n-div)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(pause "try-subs<RTRN>"))
(when (try-subs n-div)
(when verbose
(format t "~A is usable.~%" word)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(pause "return-from usable."))
(return-from usable t)))
(when verbose
(format t "~A is not usable.~%" word)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(pause "End usable."))
nil)))
....
(while (cdr cell)
(let* ((wrd (cadr cell))
(ok (usable wrd fortree baktree)))
(cond
(ok (setf cell (cdr cell))) ;move down the list
^^^^^^^^^^
(t (setf (cdr cell) (cddr cell)) ;delete the wrd
(delete-wrd wrd fortree baktree)))))
------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/
.
- Follow-Ups:
- Re: Deleting un(?)reachable code
- From: danb
- Re: Deleting un(?)reachable code
- From: D Herring
- Re: Deleting un(?)reachable code
- From: Kaz Kylheku
- Re: Deleting un(?)reachable code
- Prev by Date: Re: How do you remove an item from a list?
- Next by Date: Re: Where to file one defgeneric for two classes and two packages
- Previous by thread: Tag Heuer 2000 Exclusive Womens Watch WN1312.BA0333 Replica
- Next by thread: Re: Deleting un(?)reachable code
- Index(es):
Relevant Pages
|