Subject: bug#42147: 28.0.50; pure vs side-effect-free, missing optimizations?

From: Andrea Corallo <[email-masked]>
Date: Fri, 3 Jul 2020 19:05:40 +0000 (UTC)

Mattias Engdegård <[email-masked]> writes:

> This will be fixed automatically by marking + as pure; the same should be done for the other arithmetic functions.

Hi,

attached the updated version of the patch updating the pure function
classification.

Please have a look.

Thanks

  Andrea
From f6b7794ef72a788ecb9e6731b10fa849559f20a2 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <[email-masked]>
Date: Wed, 1 Jul 2020 10:07:57 +0200
Subject: [PATCH] * Add a number of functions to pure-fns (bug#42147)

	* lisp/emacs-lisp/byte-opt.el (pure-fns): Add: /=, <, <=, =,
	>, >=, abs, arrayp, ash, assoc, assq, bool-vector-p
	char-or-string-p, characterp, consp, eq, eql, equal, expt,
	floatp, hash-table-p, identity, integer-or-marker-p, integerp,
	keywordp, length, listp, member, memq, memql, mod, natnump,
	nlistp, not, null, number-or-marker-p, numberp, proper-list-p,
	rassq, safe-length, sequencep, string-equal, string-lessp,
	string<, string=, stringp, symbolp, vectorp.
---
 lisp/emacs-lisp/byte-opt.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 12bde8faf3..c191f438a4 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1307,9 +1307,14 @@ byte-optimize-set
 ;; values if a marker is moved.
 
 (let ((pure-fns
-       '(% concat logand logcount logior lognot logxor
-	 regexp-opt regexp-quote
-	 string-to-char string-to-syntax symbol-name)))
+       '(% /= < <= = > >= abs arrayp ash assoc assq bool-vector-p
+         char-or-string-p characterp concat consp eq eql equal expt floatp
+         hash-table-p identity integer-or-marker-p integerp keywordp length
+         listp logand logcount logior lognot logxor member memq memql mod
+         natnump nlistp not null number-or-marker-p, numberp proper-list-p
+         rassq regexp-opt regexp-quote safe-length sequencep string-equal
+         string-lessp string-to-char string-to-syntax string< string= stringp
+         symbol-name symbolp vectorp)))
   (while pure-fns
     (put (car pure-fns) 'pure t)
     (setq pure-fns (cdr pure-fns)))
-- 
2.17.1