Re: gsoc: Loop invariant hoisting
Charles Zhang <[email protected]> Sat, 23 Jun 2018 10:46:19 -0400
| Newsgroups | gmane.lisp.clisp.devel |
|---|---|
| Message-ID | <CAB=SSSnLauHjbrjhkmYYUBc2sPrGQ-sVeTaqMuPzjaRLRT9eBQ@mail.gmail.com> |
You make a good point, but the optimization definitely doesn't apply
in this case.
System function calls are only deemed 'hoistable' when they are deemed
constant foldable by CLISP. (i.e. no side effects, pure function in
terms of its inputs) I hooked into the CLISP function
SYS::FUNCTION-SIDE-EFFECTS to access this information. This limits the
hoisting to arithmetic operations +, -, *, /, and others (IDENTITY
etc.) So this mostly benefits numeric code, where the optimization is
safe to apply.
One can also argue about the following:
(lambda (n)
(dotimes (i n)
(/ n 0)))
Applying hoisting clearly gives different behavior. The solution,
which I am currently implementing, is to also hoist out the condition,
so that the hoisted computation runs only 0, or 1 times, as opposed to
N times. This, along with checking that operations cannot give
ddifferent results and cannot side effect (i.e. constant foldable),.
should be enough to guarantee no changed behavior.
Charles
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel