diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-10 08:23:34 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-10 08:23:34 -0800 |
commit | ef70b76d291b5b3a0045f2e2c1bb04a4a8a8debe (patch) | |
tree | 52eae51b4698adb1303bc4daf1ce213bd231f8f0 /RELNOTES | |
parent | 3fad0ffcf2eb07f9f9b6aba904d1ed83a35be60f (diff) | |
download | txr-ef70b76d291b5b3a0045f2e2c1bb04a4a8a8debe.tar.gz txr-ef70b76d291b5b3a0045f2e2c1bb04a4a8a8debe.tar.bz2 txr-ef70b76d291b5b3a0045f2e2c1bb04a4a8a8debe.zip |
compiler: use effect-free criterion for elimination.
When the result of a function call is not used, the call can
be eliminated if the function has no effects.
Effect-free functions are superset of constant-foldable
functions. Not all effect-free functions are const-foldable
because in some cases, creating an object at run-time is a
documented semantics which cannot be constant-folded. For
instance (list 1) cannot be constant folded, because it may be
relied upon to generate a fresh object each time it is called.
However, bringing a new list to life is not an effect. If
the value is not used, we can safely eliminate it.
The same reasoning applies to (gensym "abc"). It must generate
a unique symbol each time, and so cannot be constant-folded.
But call to gensym whose value is not used can be eliminated.
* share/txr/stdlib/compiler.tl (%effect-free-funs%): List of
side-effect-free functions registered in eval.c.
(%effect-free%): Hash of effect-free functions, incorporating
%const-foldable% also.
* share/txr/stdlib/optimize.tl (basic-blocks peephole-block):
Refer to %effect-free% rather than %const-foldable%.
Diffstat (limited to 'RELNOTES')
0 files changed, 0 insertions, 0 deletions