]> git.eshelyaron.com Git - emacs.git/commitdiff
Generalise a LAP optimisation rule
authorMattias Engdegård <mattiase@acm.org>
Sat, 25 Mar 2023 14:38:00 +0000 (15:38 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sat, 25 Mar 2023 15:21:09 +0000 (16:21 +0100)
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
Accept (stack-set 1) as equivalent to (discardN-preserve-tos 1) in a
rule previously overlooked.  This is usually beneficial in code size
and almost always shortens dynamic paths.

lisp/emacs-lisp/byte-opt.el

index 3c7aeb895259061b20939db297ed61d61dce29f4..0891ec80beb46024ef1383089e537493b89bd1da 100644 (file)
@@ -2765,7 +2765,9 @@ If FOR-EFFECT is non-nil, the return value is assumed to be of no importance."
                       (or (memq (caar tmp) '(byte-discard byte-discardN))
                           ;; Make sure we don't hoist a discardN-preserve-tos
                           ;; that really should be merged or deleted instead.
-                          (and (eq (caar tmp) 'byte-discardN-preserve-tos)
+                          (and (or (eq (caar tmp) 'byte-discardN-preserve-tos)
+                                   (and (eq (caar tmp) 'byte-stack-set)
+                                        (eql (cdar tmp) 1)))
                                (let ((next (cadr tmp)))
                                  (not (or (memq (car next)
                                                 '(byte-discardN-preserve-tos