diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-02-06 18:34:45 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-02-06 20:22:24 +0100 |
commit | 83983b6b7a115474572973b62eb5e42251713e63 (patch) | |
tree | 16df61103e1412655a7e9c4910c9c403af2fe816 /lisp/emacs-lisp/cl-print.el | |
parent | f95266ee68ab85f7a237b473f98b36413b542553 (diff) | |
download | emacs-83983b6b7a115474572973b62eb5e42251713e63.tar.gz emacs-83983b6b7a115474572973b62eb5e42251713e63.tar.bz2 emacs-83983b6b7a115474572973b62eb5e42251713e63.zip |
Constprop of lexical variables
Lexical variables bound to a constant value (symbol, number or string)
are substituted at their point of use and the variable then eliminated
if possible. Example:
(let ((x (+ 2 3))) (f x)) => (f 5)
This reduces code size, eliminates stack operations, and enables
further optimisations. The implementation is conservative, and is
strongly curtailed by the presence of variable mutation, conditions
and loops.
* lisp/emacs-lisp/byte-opt.el
(byte-optimize-enable-variable-constprop)
(byte-optimize-warn-eliminated-variable): New constants.
(byte-optimize--lexvars, byte-optimize--vars-outside-condition)
(byte-optimize--vars-outside-loop, byte-optimize--dynamic-vars):
New dynamic variables.
(byte-optimize--substitutable-p, byte-optimize-let-form):
New functions.
(byte-optimize-form-code-walker): Adapt clauses for variable
constprop, and add clauses for 'setq' and 'defvar'.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-var)
(bytecomp-test-get-var, bytecomp-test-identity)
(byte-opt-testsuite-arith-data): Add test cases.
Diffstat (limited to 'lisp/emacs-lisp/cl-print.el')
0 files changed, 0 insertions, 0 deletions