diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-08-07 18:14:42 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-08-08 11:46:18 +0200 |
commit | 89bd65197642e4700b36c270d3abf8e4a2dffbf8 (patch) | |
tree | 4a9138af3d14fa6e8c9b08b63d81d9636e270b0b /test/lisp/emacs-lisp | |
parent | eeda9eff1aa1ad973851d6589c5bcf6020a090e8 (diff) | |
download | emacs-89bd65197642e4700b36c270d3abf8e4a2dffbf8.tar.gz emacs-89bd65197642e4700b36c270d3abf8e4a2dffbf8.tar.bz2 emacs-89bd65197642e4700b36c270d3abf8e4a2dffbf8.zip |
Teach byte-compiler about Aristotelian identity
* lisp/emacs-lisp/byte-opt.el (byte-optimize-equal, byte-optimize-eq):
Optimise (eq X X) -> t where X is a variable; idem for eql and equal.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test case.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 246ffff532f..dd0c1fe91a0 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -785,6 +785,9 @@ inner loops respectively." (let ((x 0)) (list (= (setq x 1)) x)) + ;; Aristotelian identity optimisation + (let ((x (bytecomp-test-identity 1))) + (list (eq x x) (eql x x) (equal x x))) ) "List of expressions for cross-testing interpreted and compiled code.") |